Is @property implementable?
Jonathan M Davis
jmdavisProg at gmx.com
Wed Mar 2 18:36:35 PST 2011
On Wednesday 02 March 2011 18:02:18 Michel Fortin wrote:
> On 2011-03-02 20:56:41 -0500, Jonathan M Davis <jmdavisProg at gmx.com> said:
> > I would argue that properties make no sense unless they have a "this"
> > parameter to work.
>
> I would argue that properties make sense everywhere variables make
> sense. Why should they be restricted to classes and structs?
Because a property must be a property _of_ something. It's essentially an
abstraction of a member variable. It allows you to use a function as if it were
a member variable. That's its whole purpose.
What's a module/global variable a property of? The module? I really don't think
that that makes sense. A module/global variable is not a member variable, and
the use of mutable module/global variables is _not_ something which should be
encouraged anyway. So, conceptually, it doesn't really make sense for a
"property" to be on a module, and practically-speaking, I don't really see any
benefit at all. Not to mention, if it adds a layer of ambiguity (as you've
brought up), then it _really_ doesn't make sense to do that.
Regardless, I don't think that it makes any sense whatsoever for a property to
be on anything other than a user-defined type or a type which is acting like one
(like arrays or something called with UFCS). A property is an abstraction for a
member variable, not just any type of variable.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list