Just a thought: read-only fields
Nick Sabalausky
a at a.a
Mon Aug 3 19:04:51 PDT 2009
It's been established in the recent epic-discussions on properties that one
of the biggest uses for properties is to implement publically read-only (but
privately-writable) fields. That got me thinking, why not actually have real
publically read-only fields instead of merely emulating them with
properties? They are, after all, a fairly common idiom.
// *Not* an actual syntax proposal, but just to get the idea across:
private @publicread int foo;
// The class sees it as "int", but everything else sees it as "const(int)"
// ...or something like that...
More information about the Digitalmars-d
mailing list