@property needed or not needed?

Jonathan M Davis jmdavisProg at gmx.com
Tue Nov 20 11:05:50 PST 2012


On Tuesday, November 20, 2012 19:48:01 monarch_dodra wrote:
> On Tuesday, 20 November 2012 at 18:06:22 UTC, Rob T wrote:
> > Here's another way to test if the idea is sound, by asking a
> 
> > few questions:
> After thinking about it a bit more, I think there may be two
> conflicting notions:
> 
> a) The use of optional parenthesis.
> b) The @property switch, which allows a function to emulate an
> attribute, namelly, allow writting "bla = a.foo;" or "a.foo =
> 5;", when "foo" isn't actually an attribute of a.

Yes, you basically have folks who want to have strictly defined properties 
which emulate variables (similar to what C# has), and you have folks who 
simply want to leave off parens (especially when they're using UFCS and already 
forced to provide a template argument - e.g. with map or filter or whatnot). On 
some level, they can coexist, and on some level, they're conflicting notions.

Given the fact that this subject is extremely devisive, I suspect that the 
best that we can hope for at this point is for lax property enforcement - that 
is that it's enforced that @property functions are used as properties but 
there is no enforcement that non- at property functions be called with parens. We 
might be able to further restrict them so that they can't be used with the 
setter syntax (making it so that they must be @property for that to work), but 
with UFCS and the use of templated functions taking predicates, dropping 
parens is way too popular to disallow it, much as I personally hate the idea.

- Jonathan M Davis


More information about the Digitalmars-d mailing list