Properties no longer work?

Hasan Aljudy hasan.aljudy at gmail.com
Tue Jul 25 18:18:21 PDT 2006


Did properties stop working?

assuming object abc has a method foo:
# auto x = abc.foo;
gives a compiler error: x cannot be a function (or something like that)

If I change it to the following instead:
# auto x = abc.foo();
it works fine.

Here's an example:
--------
class ABC
{
	int foo() { return 10; }
}

void main()
{
	auto abc = new ABC();
	auto x = abc.foo;	
}
-----------

compiler message:
main.d(9): variable main.main.x cannot be declared to be a function

Like I said, if I add the brackets, it works fine:
-----------
class ABC
{
	int foo() { return 10; }
}

void main()
{
	auto abc = new ABC();
	auto x = abc.foo();	
}
---------

I'm suspecting this could be a bug or something, maybe due to the new 
delegate syntax.

If I change auto to int then it also works
---------
class ABC
{
	int foo() { return 10; }
}

void main()
{
	auto abc = new ABC();
	int x = abc.foo;
}
--------



More information about the Digitalmars-d-learn mailing list