Why are there Properties in D?

Jesse Phillips Jesse.K.Phillips+D at gmail.com
Fri Feb 14 07:21:03 PST 2014


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.

Being able to read and understand a piece of code has nothing to 
do with knowing exactly how it achieves its task or what the code 
the machine will be running. If there is a bug, then you'll need 
to dig into it. If there is a performance problem you've 
identified then you'll be looking at it, but in general those 
aren't important to understanding what the code does.


More information about the Digitalmars-d mailing list