On Mon, 06 Jul 2009 21:29:43 -0700, Walter Bright wrote: > Derek Parnell wrote: >> However, that aside, the syntax you have chosen will have a rational >> explanation for its superiority. So can you explain in simple terms why >> >> CaseLabelInt .. CaseLabelInt eg. case 1: .. case 9: >> >> is superior than >> >> case CaseRange: eg. case 1 .. 9: >> >> given that >> CaseLabelInt ==> case IntegerExpression : >> CaseRange ==> IntegerExpression .. IntegerExpression > > Because > > 1. case X..Y: > > looks like > > 2. foreach(e; X..Y) > 3. array[X..Y] > > yet the X..Y has a VERY DIFFERENT meaning. (1) is inclusive of Y, and > (2) and (3) are exclusive of Y. > > Having a very different meaning means it should have a distinctly > different syntax.
Thank you, but now I am confused ... Andrei just got through lecturing us that the meaning of punctuation is dependant upon context. So I think your example must be more like ... Because 1. case X..Y: looks like 2. foreach(e; X..Y) 3. array[X..Y] 4. case X:..caseY: yet the X..Y has a VERY DIFFERENT meaning. (1) is inclusive of Y, and (2) and (3) are exclusive of Y, and (4) is inclusive of Y ... oh, hang on... Sorry, but I'm just not getting the "VERY DIFFERENT" part yet. Right now, D has ".." meaning exclude-end value (2. and 3.) AND it also has ".." meaning include-end value (4.), depending on context. Ok, I admit that there is one subtle difference. Examples 2 and 3 are of the form IntExpression .. IntExpression and example 4 is CaseLabelInt .. CaseLabelInt but seriously, people are not going to notice that. We see double-dot and think "range". I know that this is not ever going to be changed so I'm not arguing that it should. (One of the most frequent bugs I have in my D programs is that I forget that X..Y excludes Y because it's not natural to me to see text that looks like "the range X to Y" but means "the range X to Y-1".) It seems that D would benefit from having a standard syntax format for expressing various range sets; a. Include begin Include end, i.e. [] b. Include begin Exclude end, i.e. [) c. Exclude begin Include end, i.e. (] d. Exclude begin Exclude end, i.e. () -- Derek Parnell Melbourne, Australia skype: derek.j.parnell
