byKey and byValue: properties or methods?

Nick Sabalausky a at a.a
Wed Jan 18 12:37:51 PST 2012


"Nick Sabalausky" <a at a.a> wrote in message 
news:jf79sh$2l7b$1 at digitalmars.com...
> "Jacob Carlborg" <doob at me.com> wrote in message 
> news:jf6e7a$1929$1 at digitalmars.com...
>>
>> method:
>> no parameters - parentheses are optional
>
> FWIW, I always do a double-take when I see code like:
>
> functionName;
> //or
> object.functionName;
>
> It sets off all mannar of "no-effect expression!" bells and buzzers in my 
> head every time I look at it, which I then have to silence.
>

Also it doesn't help that using the function name by itself (with no parens 
or &) can be used to pass a function as a template alias parameter (or just 
alias a function), instead of passing the result of the function call as the 
argument.

Plus I've spent time in other langauges where using a function name without 
parens is the way to refer to a function itself, rather than invoke the 
function. That's something I very much like: "foo" refers to the function, 
"foo()" calls the function. Period. End of story. But in D, while "foo()" 
calls a function, refering to a function is a mess: usually it's "&foo", but 
if you're aliasing it or passing it as a template alias parameter than it's 
"foo". But then if you use "foo" in other places, it calls the function 
instead of referring to it! Bleh!!! Messy, messy.




More information about the Digitalmars-d mailing list