I agree that José may have made the wrong call here, making parens an optional part of function application. Ruby damage.
But I disagree that it’s much of a problem in practice:
the compiler is more than happy to issue a warning about implicit parens, which this blog post skips over
application of a function that is the value of a variable requires a dot, e.g., myfun.() instead of myfun or myfun(), which this blog post does not mention
Resolving the question “am I referring to the function or local value?” is a matter of checking what’s in scope, kind of like one would expect in a modern, lexically scoped language
I appreciate the theoretical issue here, but in practice stuff like this would (should?) never pass code review. I’d go so far as to recommend the Credo check to disallow variable rebinding period—if you really want it in a particular file, at least you’d have to opt into it.
The erlang example with the var is disingenious because X the variable is different than x the function. Yes, you have to know that variables are uppercase, but you’d hardly make it past day 1 without knowing that.
I agree that José may have made the wrong call here, making parens an optional part of function application. Ruby damage.
But I disagree that it’s much of a problem in practice:
myfun.()
instead ofmyfun
ormyfun()
, which this blog post does not mentionThe thing is that parens-less calls are required for “syntax purposes”, as defining functions as:
Isn’t the most pleasant syntax out there. Then we would end with parentheses everywhere and it would look like M-expressions.
That’s a good point. The other way to provide this would be something like reader macros, and I do not find myself wishing we had those around.
I appreciate the theoretical issue here, but in practice stuff like this would (should?) never pass code review. I’d go so far as to recommend the Credo check to disallow variable rebinding period—if you really want it in a particular file, at least you’d have to opt into it.
I often use argument shadowing like:
Alternative is to write it as:
Or try to find an alternative name for
a
in the first case. Both of these approaches doesn’t really compels to me.The erlang example with the var is disingenious because X the variable is different than x the function. Yes, you have to know that variables are uppercase, but you’d hardly make it past day 1 without knowing that.