Closure/Stack-to-Heap Semantics

Bill Baxter wbaxter at gmail.com
Thu Sep 25 10:27:55 PDT 2008


On Thu, Sep 25, 2008 at 10:04 PM, bearophile <bearophileHUGS at lycos.com> wrote:
> downs:
>>   foreach (i; Range[0..100].endIncl) {
>
> That's a bit ugly. Ruby uses ... to denote an interval closed on the right and .. to denote an interval open on the right. But it's easy to miss the difference when you read code, so that too is bad design.

That would make a lot of sense if it is what Ruby actually did, but
unfortunately the actual roles of ... and .. are reversed from what
you just said.

E.g. from here:
http://www.techotopia.com/index.php/Ruby_Ranges
"""
  1..10    # Creates a range from 1 to 10 inclusive
  1...10   # Creates a range from 1 to 9
"""

And it's also true that it's probably too easy to overlook the difference.

--bb



More information about the Digitalmars-d mailing list