Re: Interpreter Mod We Can All Get Behind
- Posted by Gary Shingles <eu at 531p?.co.?z> Nov 22, 2007
- 647 views
Pete Lomax wrote: > > Btw, what is the deal with newlines in a triple quote? > One thing I would probably use it for is help/messagebox text, which is always > a right pain with the " and \n"& requirements, especially if they break your > stride/concentration when explaining something difficult. Another one is large blocks of HTML or CSS if you want them embedded in the code (which I generally do). Even without variable substitution it would be handy as you could replace any text with a custom routine anyway. > In this case, I would want the newlines, is this what others expect? > Eg > """ > one > two > three > """ > is "one\ntwo\nthree\n" not "one two three". Yes, the former. The newline is definitely there since you can see its effect in the source. > Obviously it gets messier when you've got dozens or hundreds of lines. > Conversely, to triple quote is +6 chars total no matter how many lines. It depends on how easy it would be to implement in the interpreter, but if it is fairly trivial and with no great overhead I would be in favour of """. > 2) If you write, say > }}} <eucode> > constant words = {"ONE", > "TWO", > "THREE" > "FOUR", > "FIVE"} > </eucode> {{{ > then words[4] will be "FIVE". That's a compelling argument. I often forget to put a comma after something if I add lines to a constant declaration, and at least the interpreter catches it. In this case it would not be too obvious where the error was when it said "subscript value 5 is out of bounds, reading from a sequence of length 4". It's the kind of error you can spend half an hour looking for. > If anything, I'd prefer it to treat a missing > comma as if it had found one. Eek, no. I'd prefer it to say: Syntax error - expected to see possibly '}', not a character string "FOUR", ^ Gary