-
Notifications
You must be signed in to change notification settings - Fork 8
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
Issues with current syntax of values in singleton expressions #713
Comments
Maybe we have to think a little harder, |
@hanjoosten I suggest we do not promote this change to the master until we have a better story to tell. |
AtomsCurrently we roughly have the following notations for atoms:
What would be wrong when we change the fourth alternative to:
Consequences
|
@stefjoosten comes to an untrue conclusion in the above comment.
It seems natural to include the double quotes in this syntax, for by doing so, we know that anything inbetween these quotes is part of the string. Double quotes within the atom's value must be escaped. |
Here's a couple of thoughts:
|
Except for the last two of the points made by @sjcjoosten , this all is nearly finished in the branch I am currently working on. I expect this to be finished somewhere next week. |
That's great to hear! Then I can reassure Stef that you don't really need the last two points. Creating a declaration for aap and noot, and adding the rules I mentioned would already do the trick. |
I'm quite reassured. I have no reason for sticking to single quoted atoms as an expression. This is how I understand the result of this discussion:
I'll try to explain it in the user documentation. Please keep an eye on that, because this type of detail can confuse novices. |
@hanjoosten: can you verify that the first entry in this issue (which I have edited), is correct? |
The problem
When looking at the current syntax, I see some minor adaptions that have to be made.
When using the value
"Mario's pizza"
as an atom, this gives problems when we want to use this atom in an expression (as a singleton). Currently that should be denoted as'Mario's pizza'
. It is obvious that the parser would complain.This is due to that fact that in an expression, we have chosen to omit the double quotes, that normally is that container for a string value, like in the population statement. If there was an obligation to write the double quotes, even in singleton expressions, we would have to write it as
'"Mario's pizza"'
. This looks rather ugly.Proposed solution (that is implemented as of Ampersand v3.9.0)
Atoms (i.e. objects, strings, dates, integers, etc.) are denoted using the same syntax both in the POPULATION statement and in an expression. Thus, string-like expressions (e.g. for objects and strings) are embedded in double quotes. Other REPRESENT TYPES use their own representations.
An expression like
r ; "Mario's pizza"
could be a valid expression. And so could bes \/ 42
This way of denoting atoms in expressions seems pretty natural.
Note that this implies that adl-files that use single quoted atoms, will no longer compile; the error that is generated is
Lexer error at line
xxx, file
yyyUnexpected character '''
Edge cases
There is an edge case, in which the solution above does not work, because the atom's name could interfere whith the syntax of expressions. An example is when the minus sign is used, as in
r; -33
, where it could be interpreted as a relational operator (the complement of 33), or as part of an atom's name (referring to the negative number '-33').To enable that all values can be used in singleton expressions, values MAY be wrapped in curly brackets. For the above edge cases, we would write
r;-33
orr;-{33}
for the complement. If we want to use a negative number, we would need to writer;{-33}
.If other edge cases would exist (even if we cannot think of any currenty), the curly brackets will save the day in all such cases.
The text was updated successfully, but these errors were encountered: