property syntax strawman

Chad J chadjoan at __spam.is.bad__gmail.com
Sun Aug 2 06:21:38 PDT 2009


Michel Fortin wrote:
> On 2009-08-02 03:43:43 -0400, Walter Bright <newshound1 at digitalmars.com>
> said:
> 
>> The alternative is to have a unique syntax for properties. Ideally,
>> the syntax should be intuitive and mimic its use. After much fiddling,
>> and based on n.g. suggestions, Andrei and I penciled in:
>>
>>    bool empty { ... }
>>    void empty=(bool b) { ... }
> 
> I like that. But then (just a question) can you do:
> 
>     void empty+=(bool b) { ... }
>     void empty++ { ... }
>     void ++empty { ... }
> 
> ?
> 

If we apply rewriting rules to expressions that are mutated (either by a
unary operator or by being the left-hand side of some kind of assignment
expression) then we get these for free.

I'd really like to /not/ have to define these extra operations.
Otherwise we end up with one of the downsides of current operator
overloads: defining all of them is a serious pain in the butt, and
getting the compiler to define all of them for you is ugly.



More information about the Digitalmars-d mailing list