@property - take it behind the woodshed and shoot it?

Jonathan M Davis jmdavisProg at gmx.com
Thu Jan 24 13:53:57 PST 2013


On Thursday, January 24, 2013 13:48:53 Sean Kelly wrote:
> On Jan 24, 2013, at 1:40 PM, Nathan M. Swan <nathanmswan at gmail.com> wrote:
> > On Thursday, 24 January 2013 at 08:35:01 UTC, Walter Bright wrote:
> >> This has turned into a monster. We've taken 2 or 3 wrong turns somewhere.
> >> 
> >> Perhaps we should revert to a simple set of rules.
> >> 
> >> 1. Empty parens are optional. If there is an ambiguity with the return
> >> value taking (), the () go on the return value.>> 
> >> 2. the:
> >> f = g
> >> 
> >> rewrite to:
> >> f(g)
> >> 
> >> only happens if f is a function that only has overloads for () and (one
> >> argument). No variadics.
> >> 
> >> 3. Parens are required for calling delegates or function pointers.
> >> 
> >> 4. No more @property.
> > 
> > What about code that's always ignored @property?
> > 
> > int delegate() _del;
> > 
> > int delegate() getDelegate() {
> > 
> > return _del;
> > 
> > }
> > 
> > auto del = getDelegate(); // does _del get called?
> 
> I think a clarification of rule 1 is that parens will be right-associative. 
> So in your example, _del would be called.

I'd argue for simply making it so that the parens are required when a function 
returns something which is callable. So, getDelegate would be illegal, 
getDelegate() would return the delegate, and getDelegate()() would call the 
delegate.

- Jonathan M Davis


More information about the Digitalmars-d mailing list