On Tue, 29 Oct 2002, David Whipp wrote:
: Larry Wall [mailto:larry@;wall.org] wrote:
: > : unary (postfix) operators:
: > :    ...   - [maybe] same as ..Inf     [Damian votes Yes]
: > 
: > I wonder if we can possibly get the Rubyesque leaving out of
: > endpoints by saying something like 1..!10.
: 
: Perhaps we could use the less-than symbol: 1 ..< 10
: 
: Similarly: 1 >..< 10  ==  2..9

That front one is backwards--it would have to be 1 <..< 10.

But the biggest problem is that 1..<$iterator> is valid syntax.

Of course, ..! and ..^ have the same problem.  But it just seems like
it's really unlikely that someone would use a unary ! or ^ on the
endpoint term.  So with 1..!$x or 1..^$x it's likely to be right if
we guess (per the longest token rule) that the operator is ..! or ..^.
The same can't be said of ..<, alas.  But at least it might produce
a syntax error when it tries to parse the >.  Or no, it wouldn't
necessarily.  This parses:

    1..<$iterator> + 1;

but wrongly as

    1 ..< $iterator > +1;

Ick.

Of course, Real Mathematicians will want [1..10) and (1..10] instead.

Double ick.

I kind like ..^ the best because ^ is currently read "exclusive of"
anyway, sort of...

And the arrow can be read "up to", at least on that end of it.  I think
that ..^ is going to be much, much more common than ^.. will be.

There's also an issue of what (1..10) - 1 would or should mean, if anything.
Does it mean (1..9)?  Does 1 + (1..10) mean (2..10)?

And what would ('a' .. 'z') - 1 mean?

I think I'd better go to bed now...

Larry

Reply via email to