hiding a class property behind a method

simendsjo simendsjo at gmail.com
Sat Feb 22 14:43:15 PST 2014


On 02/22/2014 11:33 PM, Francesco Cattoglio wrote:
> On Saturday, 22 February 2014 at 17:21:50 UTC, luka8088 wrote:
>> It seems to me that the following code should be illegal, but I am
>> uncertain of it so I am posting here for a confirmation before I post it
>> on bug tracker:
> [snip]
>
> Nice find. I guess we could add this to the list of "ugly code caused by
> calling functions without parenthesis. If parenthesis were not optional,
> I don't think that the code would behave in such a horrible way, right?

The problem isn't about optional parenthesis or properties. It's the 
fact that
you can redefine a symbol to be something entierly different, and that this
difference will only be seen if you are looking at the symbol through the
"correct" type.

C# also allows has this feature, but you have to state explicitly that 
you are
hiding an existing symbol. D as a safe-by-default language should also 
require
this.


More information about the Digitalmars-d-learn mailing list