Error-proofing syntax for: pass by reference
Error-proofing syntax for: pass by reference
Posted Feb 15, 2015 1:36 UTC (Sun) by marcH (subscriber, #57642)In reply to: Error-proofing syntax for: pass by reference by renox
Parent article: Scalar typing in the PHP world
I realize most of these languages have the same "obfuscated side effects" problem (which is actually quite a shame when you think about it), but it looks *very* different to me.
In C, maybe you could allow some kind of extension like this one to achieve the desired effect:
void f(const char *str1)
{
   int x = strlen(const str1); // reminder of prototype / immutability
And then optionally enforce the new feature with some "declare(immutability_at_caller_point)" at the top of your file(s) :-)
 
           