Properties

"Jérôme M. Berger" jeberger at free.fr
Sat Jan 10 02:05:41 PST 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Daniel Keep wrote:
> 
> 
> Michiel Helvensteijn wrote:
>> [Condensed: syntax sucks, let's introduce more!]
> 
> I might be old fashioned (get offa mah lawn!), but I've always found
> something like the following quite acceptable:
> 
> class Foo
> {
>     mixin(properties
>     ("
>         rw int bar;
>         ro float baz;
>         wo Foo zyzzy;
>     "));
> }
> 
	Note that this is a very limited use for properties. Defining
properties isn't just a question of access control (read/write, read
only, or write only). It is also a way to execute arbitrary code
each time the value is changed (or accessed), or to create
properties that don't correspond to actual data fields (complex
module and argument come to mind). How would you do that with
mixins? (Not that it would be impossible, but the syntax would
probably be horrible).

		Jerome
- --
mailto:jeberger at free.fr
http://jeberger.free.fr
Jabber: jeberger at jabber.fr
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAklocvAACgkQd0kWM4JG3k8NCwCgm0+e/mOg3pfhpaqlnCGad/tA
v2UAmwXZjHfyeGdLk5C2FthJxOW+924r
=RNrq
-----END PGP SIGNATURE-----



More information about the Digitalmars-d mailing list