Getters/setters generator

Mark via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Tue Jan 17 02:08:35 PST 2017


On Tuesday, 17 January 2017 at 09:17:56 UTC, Andrei Alexandrescu 
wrote:
> On 1/17/17 9:32 AM, Eugene Wissner wrote:
>> Ah, well thanks. I don't think it makes much sense since it 
>> would be
>> easier to write a complete setter if the user needs extra 
>> checks.
>> Accessors are there only for the generation of the standard 
>> methods,
>> that just get or set some object property.
>
> Hmmm... that's a bit of a bummer because it helps only the 
> degenerate case (accessors are there as placeholders for future 
> extensions, and otherwise offer no protection whatsoever 
> compared to a public value). The question would be then what 
> would be use cases for the accessors. Predicated setters are 
> not just a random thing one might want out of many 
> possibilities, it's a frequent pattern. -- Andrei

Given that D supports class invariants, is there a real need for 
predicated setters?


More information about the Digitalmars-d-announce mailing list