Re: mainly syntax
- Posted by Craig Gilbert <cgilbert at CENNET.MC.PEACHNET.EDU> Feb 18, 1998
- 769 views
At 06:50 PM 2/18/98 -0500, Robert Craig wrote: >I was hoping to stay out of these syntax discussions >because I'm trying to get the 2.0 beta out soon, but >you guys have sucked me into it > > <SKIPPED> > x[a..length(x)] > >A couple of years ago I almost went ahead and >implemented the thing Pete recently suggested: > x[a..] >i.e., leave off the second index of the slice and it means >"length(x)" by default. I went a step further and thought >that > x[..b] should mean x[1..b] >Then I got tired of the whole idea - why can't someone >type in "1"? Isn't 1..b going to be more readable and only >*one more keystroke?* I moved on to other things. > I don't like the "x[1..]" thing, and x[1..-1] strikes me as pretty bad also, but it looks to me like there is at least a little bit of consensus on the list about adding the x[1..end] form, like in PP, to the built-in parts of Euphoria. That I heartily agree with. Using "end" in that particular place is slightly easier to type and MUCH clearer. No, scrap the "slightly"; some guys have been using examples like x[1..length(x)] to demonstrate how it's not really that hard to type the function call 'length(x)' but that's not the problem; the problem is typing something like cur_buf = storage_buf[10..length(storage_buf)] over and over. Yes, I can predict the comments of Real Programmers about following book recommendations too much and using over-long variable names, but jeez . . . not *everything* can have a one-letter identifier! Well, it can (26 of'em, anyway), but any non-trivial program written that way better have a butt-load of comments if the programmer following you is to have the slightest chance of maintaining your code without developing a serious drinking habit. Besides, it's not necessarily *your* code you need to worry about; suppose you download some code that works well, but when you take a look at it, it turns out the coder was in favor of sentences rather than names; would you rather have to look at current_editing_buffer = or current_editing_buffer = permanent_storage_buffer[10..end] Still irritatingly overlong, but as someone else said, every little bit helps (as long as it's clear). Anyway, back to the point; I'm strongly in favor of the x[1..end] form, and I hope enough others are to persuade Mr. Craig to think about it putting it in another release down the line. However, I know nothing about the guts of an interpreter (or compiler); would that be a Bad Thing to try to add to the built-ins, in light of 'end' already being rather extensively used in the block constructs? =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- J. Craig Gilbert cgilbert at mc.peachnet.edu "Positing infinity, the rest is easy." Roger Zelazny, in 'Creatures of Light and Darkness' =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-