First class lazy Interval
Michel Fortin
michel.fortin at michelf.com
Fri Feb 27 20:40:22 PST 2009
On 2009-02-27 23:02:30 -0500, Daniel Keep <daniel.keep.lists at gmail.com> said:
> On the whole, I think the use cases for this sort of syntax are just far
> too few and specialised to warrant syntax for them, especially when the
> syntax proposed is very restrictive.
>
> Especially when you can do it in a library without too much effort.
> Hell, my first instinct was to alias inter to Z to make it even shorter.
> Then it's only 3 characters more than native syntax, and more flexible.
But what I'm proposing is that a..b just become a shortcut for
inter[a..b], or whatever is the standard interval struct in the
standard library. Isn't that exactly what you're trying to do (a
shortcut) by shortening inter[a..b] to Z[a..b] ?
> Using ... to indicate an inclusive range doesn't solve the problem. How
> do you do (a,b]? Introduce yet another operator? What about (a, b)?
Perhaps using "..." was a bit too much to ask. But there is no reason
why the standard library interval cannot support all kinds of bounds
just like inter does. The syntax just won't be as nice as a..b.
Basically, all the compiler would do is map a..b to inter[a..b] and
leave everything else to the standard library. So it's not removing any
option, it just consistently allow you to write a..b whatever the place.
--
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/
More information about the Digitalmars-d
mailing list