Re: buggy 4.0 program
- Posted by mattlewis (admin) Dec 11, 2008
- 1656 views
Igor, please let me explain why the v3 message is different to the v4 message.
In v3, when a reference to an identifier was found, it checked that the identifier had already been declared. If it hasn't it issued the message saying that 'a' had not been declared.
Ok, "declare then use", old good familiar safe simple reliable scheme.
v4 has a different approach. In v4, an identifier not is discovered missing until all the program has been parsed.
Ok, why not? But my buggy b.e program is complete, all, so to say.
There is nothing to parse any more, I do not include libs. My program
is complete but just buggy. And similar buggy 'a' we may meet in some big program too,
as typo etc etc.
Euphoria is a single pass parser, so at the time, we cannot know what will come next, or how long it will go on. Forward references are now legal, and will ultimately make coding easier. For example, if you include something in your program, you will no longer have to worry about them both including each other, requiring reorganization of code, or lots of routine ids.
A nice side effect of forward referencing is that we can report all your typos at one go, so that you can fix them all at once, without the cycle of run-fix-run-...
Instead, it assumes that a reference to an unknown identifier is valid
and continues with the parsing effort.
Why does it "think", so to say, that I'm going to use or already using the forward
referencing? I do not need the forward referencing at all, for now, maybe.
Forward referencing is a part of the language. So it thinks that you may be trying to use a forward reference the same way that a square bracket tells it that you're doing a subscript operation. If you use the standard library, then you likely are using forward referencing. There are several places where this made the libraries cleaner and easier to maintain.
I'll address the rest of the post in a separate message...
Matt