byKey and byValue: properties or methods?

Jonathan M Davis jmdavisProg at gmx.com
Tue Jan 17 16:25:33 PST 2012


On Tuesday, January 17, 2012 23:13:21 Peter Alexander wrote:
> On 17/01/12 10:11 PM, Jonathan M Davis wrote:
> > You would need to come up with some really solid arguments why it should
> > be thrown out (and what we should do instead) and get both Walter and
> > Andrei (if not the community at large) to agree that they not only
> > prefer your proposal but that it's worth the issues that the changes
> > are going to cause at this stage.
> 
> There's a few good reasons to throw it out:
> 
> 1. Avoids pointless discussions like this one. These discussions add
> nothing, it's just mindless bike shedding.
> 
> 2. The -property flag *creates* a new kind of error, but doesn't
> actually help find real problems with your code. Without properties,
> member function access would always be a.b(), and this artificial error
> could be avoided.
> 
> 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.
> 
> 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?
> 
> 5. One less language feature to implement, learn, document, debug, and
> discuss.
> 
> Is it practical or realistic to throw it out at this stage? I don't
> know. But there are reasons to.

I'm fully aware that there are those who want to throw it out (e.g. Andrei) 
and that there are reasons for doing so. My point is that those reasons 
must be strong enough to justify the cost of getting rid of @property at this 
stage in the game, or it's not going to happen. As it stands, we're going to 
have @property with it being enforced.

And there _are_ those of us who like it. I _do_ think that it's an improvement 
over what we had before. One of the primary reasons for properties IMHO is to 
be able to swap out functions and public member variables without breaking 
code, and that's not possible without something like @property with strict 
enforcement.

- Jonathan M Davis


More information about the Digitalmars-d mailing list