New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Referencing undefined variables should be an error #383
Comments
This was an intentional deviation from k (from the inception of Kona) |
Note that k4 also yields an "error" in these cases:
|
@tavmem I'm not sure I know of any times this would be desired behavior... :O |
By "this" I take you to mean the current Kona behaviour. |
k2.8 and k3.2 are inconsistent in the treatment of variables that do not exist.
After being used in a subfunction (when it does not exist), a is added to the KTREE with a null value. |
A good first step might be to eliminate Kona's propagation of function parameters to the k-tree.
In k2.8
|
The idea expressed above (Nov 16) is not worth pursuing.
Case 2:
If I stop the parser from adding the symbols to the KTREE, we get the following. Case 1:
Case 2:
Case 1 seems to work OK (except for a missing "value error" message). It may be possible to differentiate the state of a symbol added to the KTREE by the parser as a placeholder versus a symbol subsequently assigned a null value by the execution module. An attempt by the execution module to display (or use) the value of a symbol in a placeholder state could trigger a "value error". Then, at the completion of each command, it may be possible to remove placeholder symbols from the KTREE. |
To summarize: Currently in Kona:
Objective: Implement "value error" and have a KTREE that only contains symbols that have been assigned values by amend, w/o having to redesign all of Kona. There are at least 2 paths that could work. Both seem a bit kludgey. First: Create a new k-type (type 8) which would be almost identical to type 6 (Null). The parser would add type-8-nulls to the KTREE. The execution code could amend these symbols to other types. Any attempt to display or use a type-8-null in a calculation would result in a "value error". At the end of a command (during the "cleanup"), all type-8 symbols would be removed from the KTREE. Second: The third element of each entity in the KTREE dictionary is currently unused (see sample below). I believe that it was supposed to be used for attributes that were used by the k2.8 gui. Since the gui will not be implemented in Kona, this "spot" is available. The parser could add the usual type-6 nulls to the KTREE, but with a marker in the attribute position. The execution module could update these marked nulls to other types (or to assigned nulls with no marker). However, any attempt to display or use these marked nulls in a calculation would result in a "value error". The "cleanup" at the end of processing a command would remove marked nulls from the KTREE. Not clear which is a better route. sample
|
There could, of course, be other other ways that are better. |
And, it's useful to keep in mind that Kona uses recursive descent. |
The text was updated successfully, but these errors were encountered: