develooper Front page | perl.perl6.language | Postings from July 2010

Re: Suggested magic for "a" .. "b"

Thread Previous | Thread Next
From:
Darren Duncan
Date:
July 28, 2010 14:56
Subject:
Re: Suggested magic for "a" .. "b"
Message ID:
4C50A799.4000903@darrenduncan.net
Aaron Sherman wrote:
> The more I look at this, the more I think ".." and "..." are reversed. ".."
> has a very specific and narrow usage (comparing ranges) and "..." is
> probably going to be the most broadly used operator in the language outside
> of quotes, commas and the basic, C-derived math and logic ops. Many (most?)
> loops will involve "...". Most array initializers will involve "...". Why
> are we not calling that ".."? Just because we defined ".." first, and it
> grandfathered its way in the door? Because it resembles the math op? These
> don't seem like good reasons.

I would rather that ".." stay with intervals and "..." with generators.  The 
mnemonics make more sense that way.  Having ".." resemble the math op with the 
same meaning, intervals, is a good thing.  Besides comparing ranges, an interval 
would also often be used for a membership test, eg "$a <= $x <= $b" would 
alternately be spelled "$x ~~ $a..$b" for example.  I would imagine that the 
interval use would be more common than the generator use in some problem 
domains. -- Darren Duncan

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About