Reddit: why aren't people using D?
Lutger
lutger.blijdestijn at gmail.com
Fri Jul 24 15:06:46 PDT 2009
Walter Bright wrote:
> Michiel Helvensteijn wrote:
>> That's just a few reasons right there. D's properties lack elegance and
>> they lack potential.
>
> Let's start with:
>
> 1. What is a property?
A property contains information describing some object, which may or may not
be mutable.
> 2. How is that different from, say, a pure function?
A pure function is a computation without side effects:
- does not have to relate to any one object
- a mutable counterpart may not make any sense
- it cannot have any side effects while that may make sense even for a
getter (lazy load for example)
- it does not have to *describe* an object in the sense that a property does
The mechanism may be exactly the same, but a property gives a big hint to
the programmer (and tools) as to what kind of thing you are dealing with.
Extremely dumb example, all very much the same going from less to more nice:
color(corvette, Color.Red);
assert(color(corvette) == Color.Red);
corvette.color(Color.Red);
assert(corvette.color() == Color.Red)
corvette.color = Color.Red;
assert(corvette.color == Color.Red);
More information about the Digitalmars-d
mailing list