Restrict Class Properties?

Manfred Nowak svv1999 at hotmail.com
Thu Feb 22 16:16:12 PST 2007


Frits van Bommel wrote

> It's *not* normal for an assignment to a _function_ to call said
> function... 
> Some functions simply weren't meant to be properties.
As said before, to me it seems as canonical as can be to have an 
assignment be interpreted as a call. Seen this way property is just a 
synonym for function---and the last sentence of the citation above 
becomes senseless.

> So currently the line declaring & initializing x calls 'foo' and
> uses the return type as value
This explanation lets me doubt, that the whole paradigm of get/set-
properties, as presented, is of any usefulness.

If a set-property can be seen as an agent bound to a deposit box for 
input, then a get-property should return an agent capable of answering 
questions about the output, i.e. a delegate.

Do you see the consequences? The confusion you presented stems from not  
distinguishing between the type of the return value "typeof" and the 
type of the return agent "agentof":
  typeid( typeof( foo)) == "int"
  typeid( agentof( foo)) == "int()"

So "&foo" is undefined in the sense that it can approximately mean 
both:  "&typeof( foo)" and "&agentof( foo)".

-manfred



More information about the Digitalmars-d mailing list