Automatic getter/setter generation

Saaa empty at needmail.com
Thu Oct 22 17:08:47 PDT 2009


Lutger wrote:
> I'm not sure it is very useful. I can think of a couple of reasons to 
> define
> simple getter / setters:
>
> - must be done when implementing an interface
> - binary compatibility perhaps (again: interfaces)
> - you will or might add functionality to the get/set functions at a later
> stage.
>
> If these are the only reasons, I would just go ahead and implement the
> get/set functions manually. Then again it may be useful depending on your
> application.
I thought about using something like this because especially in larger 
classes
I tend to forget how certain variables are defined and this way it would all
be nicely packed at the top of the class (still fitting within a single 
screen).

>
> One more thing you could use this for is adding functionality to get/set
> functions:
>
> template DefaultImplementation(T, string name)
> template LoggingImplementation(T, string name)
> template UndoRedoImplementation(T, string name)
>
> mixin var!(DefaultImplementation(int, "_name")
> mixin var!(LoggingImplementation(int, "_name")
> mixin var!(UndoRedoImplementation(int, "_name")
>
Undo Redo, I think I've never had the use for those but maybe I'll let
them in my consciousness for a while :) 




More information about the Digitalmars-d-learn mailing list