Partial modification of DIP23 to allow module level property

Jonathan M Davis jmdavisProg at gmx.com
Fri Feb 8 21:29:55 PST 2013


On Saturday, February 09, 2013 06:15:34 Kenji Hara wrote:
> To avoid syntactic ambiguity, it's forbidden to define property
> getter callable by using UFCS.

And why is it that the global function gets to be a setter property and the 
UFCS function doesn't? What's the advantage in choosing the UFCS function as 
the one that has to be a normal function which just happens to be called 
without parens (but could be called with them) over choosing the global getter 
property to be the one that's a function that can be called without parens?

I'd much rather see the global getter have to be declared without @property 
(and rely an the ability to be called without parens but be unable to enforce 
it). And I _definitely_ wouldn't want to set a precedence for front to be 
declared as a non-property function. It needs to be consistently called 
without parens to work in generic code, and if arrays are able to use front 
with parens, then we definitely risk a lot of range-based functions being 
written incorrectly due to the fact that far too often, range-based functions 
only end up being tested with arrays, and in that case, the parens wouldn't 
cause an error like they should. It wouldn't be caught until someone actually 
tried it with another type of range (possibly much later). Granted, the writer 
of the range-based function should have tested it better, but given that 
arrays are by far the most common type of range, I think that it's just asking 
for trouble to allow their front or back to be used with parens.

- Jonathan M Davis


More information about the Digitalmars-d mailing list