Walter Bright wrote:
grauzone wrote:
I oriented this on the syntax of array slices. Which work that way. Not inconsistent at all. It's also consistent with foreach(_; x..y).

It would look consistent, but it would behave very differently. x..y for foreach and slices is exclusive of the y, while case x..y is inclusive.

Creating such an inconsistency would sentence programmers to forever thinking "which way is it this time".

To avoid such confusion an obviously different syntax is required.

This isn't a matter that's very important to me, as I rarely use case statements, but the suggestion made elsewhere of allowing restricted pattern matching of some sort, or concatenated logical tests, is appealing. Being able to test for (e.g.)
case (< 5 & > j):
would be very appealing. (I read that as case less than 5 and greater than j.)

OTOH, I'm not at all sure that such a thing could be implemented efficiently. The places that I've usually found such things were in languages interpreted at run time.

Reply via email to