property syntax strawman

Michel Fortin michel.fortin at michelf.com
Mon Aug 3 08:42:51 PDT 2009


On 2009-08-03 10:06:23 -0400, "Robert Jacques" <sandford at jhu.edu> said:

> On Mon, 03 Aug 2009 00:27:45 -0400, Nick Sabalausky <a at a.a> wrote:
> 
>> "Robert Jacques" <sandford at jhu.edu> wrote in message
>> news:op.ux2gvcvi26stm6 at sandford.myhome.westell.com...
>>> 
>>> I agree 1) is an issue, but I view it as a corner case. (I use zero/one
>>> arg functions all the time and make use of the 'property' syntax left
>>> right and center, but I've never run into the opCall problem) It would  be
>>> nice if it were fixed, but we may be cutting off the nose to spite the
>>> face, as it were. (Or alternatively, taking the scientific instead of
>>> engineering approach)
>>> 
>> 
>> It'll become a major PITA when D gets used for heavy functional-style  stuff.
> 
> Maybe. But how often will people return zero-argument opCalls (function 
>  pointers/delegates/structs) from zero-argument functions? (i.e. how 
> often  do you run into this today?)

The compiler isn't as smart as you think. This doesn't compile, it 
requires an empty pair of parenthesis:

	void delegate(int) func();

	func(1);

And I somewhat doubt it should be smart enough for this, because if you 
then add a overloaded function "func" that takes an int you're silently 
chaning the meaning of the code.

Solve this for fun:

	void delegate() func(int);
	void delegate(int) func();

	func(1); // which one?

-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/




More information about the Digitalmars-d mailing list