From: Zach Dennis Date: 2004-10-01T04:50:04+09:00 Subject: Re: Range syntax theory Massimiliano Mirra - bard wrote: >Zach Dennis writes: > > > >>I have been thinking lately about rangess and I will give you the two >>different range operators and what comes to mind first. >> >> > >Whose mind? > > Obviously the email is going to be based on a bias by the OP...me. The whole sentenced was based around "I have", "I will", etc...so it should be of no surprise to bridge the next logical gap and consider it to be my mind. Nor did I ever mention or even give the slightest implication that this was the result of anyone else's mind, or a collective of thoughts from a group of people. > > >>Operator One: .. (two dots) >>Example: 1..5 >>What comes to mind: Exclusive >>How It Works: Inclusive (the last number 5, is included) >> >>Operator Two: ... (three dots) >>Example: 1...5 >>What comes to mind: Inclusive >>How It Works: Exclusive (the last number 5, is excluded) >> >> > >I'd be curious to know, provided it lies close enough to the >consciousness level, why 1..5 brings to your mind the idea of >exclusive whereas 1...5 brings to your mind the idea of inclusive. > > > The '..' and the '...' are used only in the context which includes both of those operators (or methods..i know they are methods). If you take them outside of that context to where '..' is viewed separately then I agree I can come to the same conclusion as you. It means 1 to 5. But when you put it in a larger context which includes '...' and consider the behavior of both '..' and '...' then it appears that they are backwards. Two dots is less then three, so you would assume that two dots would include less values, then that of three dots. I have not seen a reasonable argument for why the other way around, besides that it is the way it is done now. >1...5 is simply nothing I had ever thought of and, as such, it >couldn't go against anything that came to mind (since nothing came to >mind). A couple of years ago someone here wrote something like ``Just >think of it as the same of 1..5, just with the 5 pushed aside and thus >not reached''. I didn't need anything else. > >But, of course, I might just be one among a thousand with something in >my head wired backwards. Then again, I might not. > > I don't think your mind is wired backwards. I think you are arguing your point based on '..' alone. And I agree with you when I do that. My best guess is that the '..' was created in whatever language it showed up in first. Later down the road someone came up with the idea to have an "exclusive" range operator and they implemented the '...' so they would not break compatibility. I do not have a problem with the current behavior except that it isn't natural, and it isn't the expected behavior *unless* you have already learned what '..' and '...' do. My hope is that as Ruby becomes a better language in the future that this be rethought. I think that as Ruby becomes more natural it should do so in every way possible, where it makes sense (which is of course Matz's decision to make, where these improvements are made). We have already discovered on this thread alone that many people had to retrain their brain to accept the behavior of '..' and '...'. Wouldn't it be great if future programmers didn't have to do that? If we made it one more step more natural to where it makes sense to the programmer? Of course these are rhetorical questions. I don't expect anyone to answer them. If Matz decides that the Range theory I have posted in this thread isn't the direction he wants to take Ruby in, then I am 100% ok with that. I have already trained my brain to accept '..' and '...' behavior. If he thinks it is a good idea then that is 100% ok with me to. I trust that whatever direction Matz takes Ruby in will be the best one and I do not want to influence his decision unless some of my reasoning or argument makes sense for him to do. I will still use Ruby either way. You don't see me posting this on a Perl list now do you? Zach