Changes before 1.0

Oskar Linde oskar.lindeREM at OVEgmail.com
Mon Dec 4 02:32:44 PST 2006


Miles wrote:
> Jordan Miner wrote:
>> Sometimes using the property syntax causes a compiler error:
> 
> Properties are also broken for cases like:
> 
> 	button.width -= 5;
> 	cursor.position++;
> 
> This is the essence of properties (it should be completely transparent
> for the user if it is accessing a variable or calling a method), yet D
> doesn't support it properly. This has the potential to break a lot of
> code when you convert variables into properties.

What is sad is that with the current property syntax, D can *never* 
achieve transparency. Even if ++a.x would be transformed into 
a.x(a.x()+1) there are cases that can never be transformed into an 
"accessor" property and make the accessing code remain the same. E.g:

struct Type {
	int delegate() prop;
}

Type t;

Used:
	t.prop()


Try transforming that into an accessor property:

struct Type {
	int delegate() prop() { return { return 0; }; }
}

Now, t.prop() will have a different meaning.

The problem here is that the trailing parenthesis pair () is allowed but 
not necessary. t.prop() could mean both t.prop and t.prop()().

/Oskar




More information about the Digitalmars-d mailing list