[Bro-Dev] functions truly as globals?
Siwek, Jonathan Luke
jsiwek at illinois.edu
Fri Sep 27 13:28:20 PDT 2013
>> some_func = my_func;
> Please, no ... That's not only hurting readability profoundly but also
> prevents function-level code optimization. Just imagine the impact
> once we start compiling scripts ...
Doesn't readability improve if it makes functions behave in a way more consistent w/ other data types? E.g. if you don't want a value to change at run-time, use the "const" modifier, but if you do, use "local" or "global" depending on what scope is appropriate (though actually using the later with that intention isn't recommended or whatever we want to do/say about it).
Right now, the rules for whether you can assign to a variable of function type at run time are a bit dicey. I think you can always assign a function value if it's "local". And you can actually assign to a "global" only if it doesn't already have a value (a function body/definition). Most people probably don't encounter these, but I do think it is jarring.
Changing most/all existing "global" function declarations to use "const" instead would help some, but what about the other inconsistencies?
More information about the bro-dev