1. Suboptimal error message
- Posted by Juergen Luethje <j.lue at gmx.de> May 18, 2005
- 431 views
Hi all, this is not a big issue, but maybe interesting for Rob anyway. Recently, I had the following code:
constant a = 1, b = 2 sequence s -- ... more stuff
Then I deleted the 3rd line, but forgot to delete the trailing comma in the 2nd line:
constant a = 1, sequence s -- ... more stuff
Running this code with exw.exe 2.5 produced the following error message: ---------------------------------------------------- C:\temp\test.exw:4 Syntax error - expected to see possibly this ..., not a variable sequence s ^ Press Enter ---------------------------------------------------- a) I think the token "sequence" should already cause a syntax error, because it's not allowed at that place. b) What did Euphoria expect to see? Three dots? Regards, Juergen
2. Re: Suboptimal error message
- Posted by Robert Craig <rds at RapidEuphoria.com> May 18, 2005
- 409 views
- Last edited May 19, 2005
Juergen Luethje wrote: > this is not a big issue, but maybe interesting for Rob anyway. > Recently, I had the following code: > > }}} <eucode> > constant > a = 1, > b = 2 > > sequence s > -- ... more stuff > <font color="#330033"></eucode> {{{ </font> > > Then I deleted the 3rd line, but forgot to delete the trailing comma in > the 2nd line: > > }}} <eucode> > constant > a = 1, > > sequence s > -- ... more stuff > <font color="#330033"></eucode> {{{ </font> > > Running this code with exw.exe 2.5 produced the following error message: > ---------------------------------------------------- > C:\temp\test.exw:4 > Syntax error - expected to see possibly this ..., not a variable > sequence s > ^ > > Press Enter > ---------------------------------------------------- > > > a) I think the token "sequence" should already cause a syntax error, > because it's not allowed at that place. "sequence" is not a keyword. You can declare a variable or constant called "sequence" (if you are insane ). So the syntax is ok up to that point. > b) What did Euphoria expect to see? Three dots? No, it's just a coding problem in the front end. For some reason, LexName() in emit.e didn't know what else to call the token, other than "...". I'll fix it for the next release. Thanks, Rob Craig Rapid Deployment Software http://www.RapidEuphoria.com
3. Re: Suboptimal error message
- Posted by "Juergen Luethje" <j.lue at gmx.de> May 18, 2005
- 403 views
- Last edited May 19, 2005
Robert Craig wrote: > Juergen Luethje wrote: <snip> >> }}} <eucode> >> constant >> a = 1, >> >> sequence s >> -- ... more stuff >> </eucode> {{{ >> >> Running this code with exw.exe 2.5 produced the following error message: >> ---------------------------------------------------- >> C:\temp\test.exw:4 >> Syntax error - expected to see possibly this ..., not a variable >> sequence s >> ^ >> >> Press Enter >> ---------------------------------------------------- >> >> >> a) I think the token "sequence" should already cause a syntax error, >> because it's not allowed at that place. > > "sequence" is not a keyword. You can declare a variable > or constant called "sequence" (if you are insane ). > So the syntax is ok up to that point. Uuhhh, I didn't know that. <scratching my head like Stan Laurel> Wouldn't it be better not to allow things like that? Or would that require heavy changes of the interpreter? Of course, disabling that in a future Eu version can break existing code, but only code that should be rewritten anyway. <snip> Regards, Juergen
4. Re: Suboptimal error message
- Posted by Robert Craig <rds at RapidEuphoria.com> May 18, 2005
- 417 views
- Last edited May 19, 2005
Juergen Luethje wrote: > Robert Craig wrote: > > "sequence" is not a keyword. You can declare a variable > > or constant called "sequence" (if you are insane ). > > So the syntax is ok up to that point. > > Uuhhh, I didn't know that. <scratching my head like Stan Laurel> > Wouldn't it be better not to allow things like that? Or would that > require heavy changes of the interpreter? > Of course, disabling that in a future Eu version can break existing > code, but only code that should be rewritten anyway. It actually makes some sense. Types in Euphoria are defined via special 1-parameter functions. So "sequence" is really a kind of pre-defined function, e.g. if sequence(x) then ... though most people tend to think of it as a reserved keyword. Regards, Rob Craig Rapid Deployment Software http://www.RapidEuphoria.com
5. Re: Suboptimal error message
- Posted by Pete Lomax <petelomax at blueyonder.co.uk> May 19, 2005
- 401 views
On Wed, 18 May 2005 23:27:01 +0200, Juergen Luethje <j.lue at gmx.de> wrote: >Robert Craig wrote: >>> Syntax error - expected to see possibly this ..., not a variable > >Uuhhh, I didn't know that. <scratching my head like Stan Laurel> >Wouldn't it be better not to allow things like that? Or would that >require heavy changes of the interpreter? FYI, the 2.4 error was Syntax error - expected to see possibly '=', not a variable Of course all the code involved here is now public domain (eu.ex and/or parser.e and/or and emit.e), albeit packaged specially. An interesting thing to attempt would be to backtrack at the error point (add zero overhead in the non-error case, please), possibly looking through the most recently added var names for something rather suspicious (probably including user-defined types). I'm sure Rob would thank you if you came up with something clever in that area. You might even get close to perfection here: point at the comma and say "that comma should probably not be there"? (But I doubt it Regards, Pete
6. Re: Suboptimal error message
- Posted by Pete Lomax <petelomax at blueyonder.co.uk> May 19, 2005
- 394 views
On Wed, 18 May 2005 16:50:29 -0700, Robert Craig <guest at RapidEuphoria.com> wrote: <snip> >It actually makes some sense. What/which did you mean makes some sense? (Myself, I'm ok with integer integer, providing that you don't expect to be able to define another integer anytime soon, not that I'll ever use or miss it. However I'd obviously prefer better error messages at the expense of this "flexibility". There were a few cases I found in existing code where a user-defined type was also used as a local variable in win32lib and the IDE, as I recall, but all easily fixable) Regards, Pete PS I can't remember clearly, either Derek or Judith or both made some changes already when I queried this last year sometime.
7. Re: Suboptimal error message
- Posted by Robert Craig <rds at RapidEuphoria.com> May 19, 2005
- 399 views
Pete Lomax wrote: > > On Wed, 18 May 2005 16:50:29 -0700, Robert Craig > <guest at RapidEuphoria.com> wrote: > > <snip> > >It actually makes some sense. > What/which did you mean makes some sense? I just meant it made some sense that "sequence" was a predefined symbol that could be redeclared by the user, rather than a reserved keyword, since all types in Euphoria are ceated by declaring a function of one argument, but using "type" instead of "function". Predefined functions and procedures can be redeclared by the programmer as something else. Euphoria predefines "sequence", "integer", "atom" and "object" for you, just as it does "sin", "cos", "repeat" etc. Regards, Rob Craig Rapid Deployment Software http://www.RapidEuphoria.com
8. Re: Suboptimal error message
- Posted by "Juergen Luethje" <j.lue at gmx.de> May 20, 2005
- 394 views
Pete Lomax wrote: > On Wed, 18 May 2005 23:27:01 +0200, Juergen Luethje wrote: > >> Robert Craig wrote: >>>> Syntax error - expected to see possibly this ..., not a variable >> >> Uuhhh, I didn't know that. <scratching my head like Stan Laurel> >> Wouldn't it be better not to allow things like that? Or would that >> require heavy changes of the interpreter? > > FYI, the 2.4 error was > Syntax error - expected to see possibly '=', not a variable Ah, I see. > Of course all the code involved here is now public domain (eu.ex > and/or parser.e and/or and emit.e), albeit packaged specially. I really appreciate the Public Domain release of Eu in Eu. But the code is rather complex and not easy to understand for me. I probably should take a looong rainy Sunday afternoon to look at the code again. Unfortunately, currently the weather is fine here. > An interesting thing to attempt would be to backtrack at the error > point (add zero overhead in the non-error case, please), possibly > looking through the most recently added var names for something rather > suspicious (probably including user-defined types). I'm sure Rob would > thank you if you came up with something clever in that area. > > You might even get close to perfection here: point at the comma and > say "that comma should probably not be there"? (But I doubt it If it would be not allowed to use "object", "sequence", "atom" and "integer" as variable names (please see me other recent post in this thread) then I think this would be rather easy: Just when one of these four tokens is preceeded by a comma, Eu should throw exactly this error message. Because based on experience (AFAIK and IMHO, of course) this actually is the most probable cause. Regards, Juergen
9. Re: Suboptimal error message
- Posted by "Juergen Luethje" <j.lue at gmx.de> May 20, 2005
- 395 views
Pete Lomax wrote: > On Wed, 18 May 2005 16:50:29 -0700, Robert Craig wrote: > > <snip> >> It actually makes some sense. > What/which did you mean makes some sense? > > (Myself, I'm ok with integer integer, providing that you don't expect > to be able to define another integer anytime soon, not that I'll ever > use or miss it. However I'd obviously prefer better error messages at > the expense of this "flexibility". There were a few cases I found in > existing code where a user-defined type was also used as a local > variable in win32lib and the IDE, as I recall, but all easily fixable) IMHO in such cases Euphoria simply should stop parsing and generate a syntax error. Even if it was easily fixable by you, what about less experienced programmers, especially Euphoria mewbies? And is there any advantage in allowing things like that? I'm not asking for much, I only want Euphoria to be to cleanest, best readable, most simple and most robust programming language on this planet. > Regards, > Pete > PS I can't remember clearly, either Derek or Judith or both made some > changes already when I queried this last year sometime. Regards, Juergen