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

Timon Gehr timon.gehr at gmx.ch
Thu Jan 24 17:01:35 PST 2013


On 01/25/2013 12:23 AM, Adam Wilson wrote:
> ...
>
> But what happens if t.baz returns a delegate?
>

You mean, a parameterless delegate. How many times does this occur that 
it supports nuking a entire language feature?

> Because properties, which conceptually have nothing to do with
> functions, are implemented as functions they have the same optional
> parens rules as functions.

Because the compiler is broken.

> The problem is that they aren't intended to
> be used as functions so in the case of delegate, you get massive
> explosions in the compiler. For something that should be
> straight-forward. If t.baz is a delegate than t.baz() should call the
> DELEGATE, but it doesn't...
>

It should for @properties.

> Optional Parens Encourage Ambiguity.

We could talk about fixing that particular situation, eg, only allow 
paren-free calls when no parameterless callable is returned, with a very 
explicit error message. (Like Jesse suggests as well.)

However, note that scala does the same we do now:
scala> def foo()=()=>2
foo: ()() => Int

scala> foo
res1: () => Int = <function0>

scala> foo()
res2: () => Int = <function0>

scala> foo()()
res3: Int = 2

I do not think this is a recurring discussion topic on the scala 
newsgroup. I think we might actually be fine.

> Ambiguity Fosters Bugs.
>

Delegates not being called is noticed quickly.


More information about the Digitalmars-d mailing list