Changes before 1.0

Leandro Lucarella llucarella at integratech.com.ar
Mon Dec 4 07:55:58 PST 2006


Miles escribió:
> 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.

I think you can add this to the thread "Python-like tabs instead of 
curley brackets?" where Walter says:

"Every programming language has some stupid mistake in it that sounded 
like a good idea at the time:
[other languages problems]
D: I'm sure you all have your own ideas for this!"

I mean, properties are great, but to be really useful they have to 
support the same semantics as regular variables. Maybe somethig as 
simple as translating button.width -= 5; as cursor.position = 
button.width - 5; is enough. Postfix incrementation is maybe the only 
problematic one, but could be done with something like:
{
	auto tmp = cursor.position;
	cursor.position = cursor.position + 1;
	return tmp;
}
(I think you'll get the idea ;)

This last scheme could be generally used to implement the other 
operators: 1) make a copy of the property 2) operate over the copy 3) 
update the property.

Or maybe the "stupid mistake" is deeper and it comes from the side of 
treating differently POD and objects...

-- 
Leandro Lucarella
Integratech S.A.
4571-5252



More information about the Digitalmars-d mailing list