property syntax strawman

Michiel Helvensteijn m.helvensteijn.remove at gmail.com
Sun Aug 2 12:44:20 PDT 2009


Michel Fortin wrote:

>> In my design, they are actual functions with actual names.
>> 
>> For D this doesn't really work. If you want symbolic placeholders, you
>> may want to use something other than 'get' and 'set'. For example, 'in'
>> and 'out' have been suggested by some. They are already keywords.
> 
> One thing with in and out makes me uneasy. Imagine a setter/getter with
> a contract:
> 
> int prop.out()
> out (result) { assert(result > 3); }
> body { return something; }
> 
> void prop.in(int v)
> in { assert(v > 3); }
> body { something = v; }
> 
> Wouldn't it be a little confusing having twice the same keyword so
> close but with a completly different meaning?

I agree, it's far from ideal. Well, I'm sure a solution can be found. It's
now just down to detail.

-- 
Michiel Helvensteijn




More information about the Digitalmars-d mailing list