|
|
Subscribe / Log in / New account

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 don't think you can really transpose this logic to many top-tier languages like C, Java, Python,... since they have a SINGLE way to pass parameters anyway, entirely missing this value-vs-reference distinction.

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) :-)


to post comments


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds