Why are there Properties in D?

Robin robbepop at web.de
Fri Feb 14 08:16:27 PST 2014


On Friday, 14 February 2014 at 15:21:04 UTC, Jesse Phillips wrote:
> On Friday, 14 February 2014 at 14:55:02 UTC, Robin wrote:
>> As far as I can imagine you could also implement ranges via 
>> front and empty functions and ranges could easily expose their 
>> variables as a getter method named front() or empty() and 
>> nobody would care if it is handled functionally or via a 
>> simple variable again.
>
> FYI an infinite range is defined to have
>
>     struct Infinite {
>         enum empty = false;
>     }
>
> You know it will never be empty at compile time.

Hiho,

thank you for this interesting input. =)

Couldn't this be equally possible (also at runtime) with the 
following:

struct Infinite {
     enum empty_ = false;
     bool empty() pure { return empty_; }
}

?

Robin


More information about the Digitalmars-d mailing list