"with" still sucks + removing features + adding features
Rainer Deyke
rainerd at eldwood.com
Mon May 18 19:05:14 PDT 2009
Bill Baxter wrote:
> Agreed. If you tell someone a .. b means a non-inclusive range
> from a to b, then ask them to guess what blarf a .. blarf b means,
> I would be very surprised if many guessed "inclusive range from blarf
> a to blarf b".
Agreed.
Although non-inclusive ranges are common enough that they deserve their
own syntax, I think inclusive ranges are *also* important enough to
deserve their own syntax. Writing '+1' is often error-prone or even
just plain wrong (such as when it leads to integer overflow).
I favor the syntax 'a ... b' for inclusive ranges. It's easy to read
and similar to 'a .. b' without being too similar. It does require the
programmer to pay attention, but that's unavoidable. From there, it
naturally follows that 'case's in a 'switch' statement should follow the
same convention.
I don't believe it makes any sense to have inclusive ranges in 'switch'
statements and non-inclusive ranges everywhere else. Inclusive ranges
are fairly common outside 'switch' statements, and non-inclusive ranges
are fairly common in 'switch' statements.
--
Rainer Deyke - rainerd at eldwood.com
More information about the Digitalmars-d
mailing list