Re: Rob, no reply? Minor bug found in 3.1 and previous
- Posted by CChris <christian.cuvier at agr?culture.gouv.fr> Jul 07, 2007
- 564 views
Al Getz wrote: > > Robert Craig wrote: > > > > I don't plan to do anything about this. > > It's a rare situation, and I don't think it's > > worth the trouble to try to improve the error message. > > > > Al Getz wrote: > > > > > > Al Getz wrote: > > > > > > > > Robert Craig wrote: > > > > > > > > > > Al Getz wrote: > > > > > > > > > > > > --program: > > > > > > constant x=1 > > > > > > x=2 > > > > > > --end program > > > > > > > > > > > > --error message: > > > > > > C:\Euphoria\Projects\Test\test.exw:2 > > > > > > x has not been declared > > > > > > x=2 > > > > > > ^ > > > > > > > > > > > > Press Enter > > > > > > --end message > > > > > > > > > > > > > > > > > > Error message should be "May not change the value of a constant", > > > > > > or something like that. > > > > > > > > > > Yes, that would be a better message. > > > > > You've caught the parser and scanner at an awkward moment. > > > > > What's happening here is that you're making the scanner > > > > > look up x in the symbol table, when the parser hasn't quite > > > > > finished the constant declaration of x. The fact that > > > > > you enter a new-line character after constant x = 1 > > > > > is no more significant than typing a blank, and > > > > > the parser needs to see the next scanner token to be sure that > > > > > the constant declaration is really finished. You might have > > > > > had: > > > > > }}} <eucode> > > > > > constant x = 1 > > > > > + 1 -- x is 2 > > > > > </eucode> {{{ > > > > > for instance. Until the parser digests the next token after " = 1", > > > > > it can't be sure that the declaration is finished, > > > > > and can't record that x is a constant with value 1 > > > > > in the symbol table. > > > > > > > > > > Regards, > > > > > Rob Craig > > > > > Rapid Deployment Software > > > > > <a > > > > > href="http://www.RapidEuphoria.com">http://www.RapidEuphoria.com</a> > > > > > > > > > > > > Hi Rob, > > > > > > > > > > > > Ok, but it looks to me like logically it is not too hard to detect > > > > the end of a constant declaration. Whether or not the parser can > > > > do this yet or not i dont know, apparently it can not. > > > > > > > > I think i see what you are talking about however, in that the > > > > following program gives the same error: > > > > > > > > -- > > > > constant y=2 > > > > constant x=y x=1 > > > > -- > > > > > > > > Apparently though something sees the whitespace and is able to terminate > > > > the > > > > "x=y" part once the 'x' is encountered, it is just not able to > > > > understand > > > > the difference > > > > between a comma or whitespace or other, non-variable-starter characters > > > > (which would tell it to keep parsing the constant declaration) and > > > > an actual variable-starter character. > > > > In other words, if it encounters a character that is in the set of > > > > all characters that can be a variable starter then it is forced to > > > > terminate the constant declaration. Isnt the current set A to Z and > > > > a to z ? Note there is no possibilty of: > > > > > > > > constant x=y x --(which would trigger an "x is not declared" error) > > > > > > > > where the user intended > > > > > > > > constant x=yx > > > > > > > > > > > > and also > > > > > > > > constant x=x > > > > > > > > would probably trigger an "x is not declared" error (referring to > > > > the second x). > > > > > > > > > > > > Make sense or did i assume too much? > > > > > > > > > > > > Bottom line is that the main reason i mentioned this is because > > > > when you get the error message "x is not declared" it makes you > > > > think you can go somewhere near the beginning of the program and > > > > type "atom x" and all will be fine > > > > Only after typing that will the real problem show itself (x was > > > > already declared as a constant) on the next run. > > > > > > > > > > > > Al > > > > Regards, > > Rob Craig > > Rapid Deployment Software > > <a href="http://www.RapidEuphoria.com">http://www.RapidEuphoria.com</a> > > > Hi again, > > > Yeah, im not going to loose any sleep over this either, but i thought > for completeness it was worth mentioning. Someday, somebody, somewhere, > may wish to see a Euphoria with zero bugs (or at least all the known ones > eliminated). > > > Al > > E boa sorte com sua programacao Euphoria! > > > My bumper sticker: "I brake for LED's" > I can't count the number of times Eu gives me an error which is not the one I committed. This is not specific to Euphoria. The error meaasges are laid in the logic of the parser or scanner, which are completely alien to the coder's. These are not bugs, since they re not behaviours different from documented ones. Second guessing the coder would be a somewhat huge investlment, probably more adequate in an IDE - there is currently none for Euphoria proper - than inside the Euphoria interpreter. It would certainly be useful though. When I said there is none, this not exactly true. Visual Euphoria v1.02 by "average Joe" is a starting point. Not an full fledged IDE for sure, but adding to it could make it into it. I have already enhanced it a lot, have to retrieve the right set of includes to make it work again. CChris