Uniform Function Call syntax for properties
Nick Sabalausky
a at a.a
Fri Oct 8 14:48:51 PDT 2010
"Jonathan M Davis" <jmdavisProg at gmx.com> wrote in message
news:mailman.483.1286572389.858.digitalmars-d at puremagic.com...
> On Friday, October 08, 2010 13:56:14 Nick Sabalausky wrote:
>>
>> Additionally, with that understanding in place, this:
>>
>> @property void foo(int x) {...}
>> (3).foo();
>>
>> Is probably the one place where UFC syntax should never be allowed,
>> because
>> it's obviously a setter, and since when does this ever make any sence:
>>
>> int x;
>> (3).x; // Set x to 3?? WTF??
>
> If literals are considered const or immutable, then this takes care of
> itself,
> since then the type system would then disallow it.
>
Maybe hunger is blinding me ATM, but don't see how. Unless it would also
prevent this:
void bar(int a) {...}
bar(3); // Cannot implicitly cast away immutable
But that would obviously be a bad thing. And even at that, there's still
this that would need to be prevented:
@property void foo(int x) {...}
int x = cast(int)3;
x.foo; // Set foo to 3 with stupid syntax
More information about the Digitalmars-d
mailing list