byKey and byValue: properties or methods?

Manfred Nowak svv1999 at hotmail.com
Tue Jan 17 21:26:43 PST 2012


Andrei Alexandrescu wrote:

>> 1. Avoids pointless discussions like this one. These discussions
>> add nothing, it's just mindless bike shedding.
> Yes.
But only because it is planned to create a massive difference between 
calls with and without parantheses.

The original idea to use mascerading functions to control every 
access to a variable seems to be lost thereby. That control might 
include logging the access, as it is necassary e.g. in bank 
management.

[...] 
>> 3. Properties introduce another thing to remember, with no value
>> ("was it byKeys, or byKeys()?"). Without properties, it would be
>> byKeys(). No need to remember.
> YES!!!
But only because the original question already is ambiguous. 
`byKeys' mascerades a _variable_ as a function, by prefixing it with 
letters "by".


>> 4. Properties obfuscate code. Is (a.b = c) a variable assignment
>> or arbitrary function call? Who knows! Is a.b an actual variable?
>> Can I write &a.b to get its address, or is it a function
>> masquerading as a variable?
> Hm, actually that's not bad.
If the coder has forgotten, that variable `a.b' is a sheltered 
variable, then reminding her/him on that by an error is more that 
"not bad".

>> 5. One less language feature to implement, learn, document,
>> debug, and discuss.
> Back to yes.
What other way is planned to control access to variables especially 
for logging?

 
>> Is it practical or realistic to throw it out at this stage? I
>> don't know. But there are reasons to.
> Me neither. If I had my way I'd carefully redo the feature to only
> require @property on rare cases that would otherwise be ambiguous,
> and make parens optional everywhere else.
Making something optional violates orthogonality and therefore should 
be used with reason.

I do not see such a reason, but I see, that it might be usefull to 
inform the called function, that it called with parans and therefore 
is known to be a function and not a sheltered variable. Then let the 
called function decide what to do with this info.

For example a call with paranthesis can turn off logging, especially 
when the call is made inside the module, wherein the function is 
specified.

-manfred 





More information about the Digitalmars-d mailing list