Methods require no parantheses

Jonathan M Davis jmdavisProg at gmx.com
Fri Apr 20 20:44:24 PDT 2012


On Saturday, April 21, 2012 05:26:21 Stian Pedersen wrote:
> Why is this possible? Just had a bug because of it. Would be
> preferable that you have to state @property. From what I can see
> the @property is optional.
> 
> int main(string[] argv)
> {
> 	int a()
> 	{
> 		return 1;
> 	}
> 
> 	int b = a;
> 
> 	return 0;
> }

It predates @property. Previously, there was no @property, and pretty much any 
function which would qualify as a property function colud be called with or 
without parens. Eventually, only functions which are marked @property will be 
able to be called without parens, and all functions with @property will _have_ 
to be called without parens. But that's being phased in rather than being 
changed immediately and breaking a lot of existing code (it also gives the 
compiler the chance to get its property enforcement bugs ironed out). For now, 
if you compile with -property, that will enable strict property enforcement. 
Later, it will always be enforced, but not yet.

- Jonathan M Davis


More information about the Digitalmars-d mailing list