Make dur a property?

monarch_dodra monarchdodra at gmail.com
Thu Jan 24 01:28:57 PST 2013


On Thursday, 24 January 2013 at 06:34:58 UTC, Andrei Alexandrescu 
wrote:
> On 1/24/13 1:18 AM, monarch_dodra wrote:
>> On Wednesday, 23 January 2013 at 23:39:50 UTC, Andrei 
>> Alexandrescu wrote:
>>>
>>> We need a good DIP on this. UFCS has destroyed all arguments 
>>> in favor
>>> of requiring parens. There is no question we must do this. 
>>> Anyone
>>> inclined toward writing a detailed DIP?
>>>
>>> Andrei
>>
>> What about optional parens on non-UFCS calls, is there a case 
>> for this?
>> Honest question.
>
> Let them be.
>
>> I'm inclined to writing a DIP.
>
> That would be great!
>
>
> Andrei

We actually have one, which I think I agree with:
http://wiki.dlang.org/DIP21

The gist of the DIP is that something marked with @property is 
always and immediately expanded into a call.

This fits into my proposal of:
1) properties never have parens (they are added by the compiler)
2) You can't take the address of a property function: "&foo" 
would become "&foo()", so you'd always get the address of the 
return value.

- make parens optional for everything else.
- allow the "foo = 5" rewrite into "foo(5)" only for properties.
-- Note that if foo is a non-property that returns by ref, then 
"foo = 5" remains legal
-- However, "writeln = 5" would be illegal.

I think properties is a really cool & powerful concept. It got 
conflated into "optional parens". This doesn't mean we should 
just "take it out back"...


More information about the Digitalmars-d mailing list