-
Notifications
You must be signed in to change notification settings - Fork 3
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
Reconcile differences between parsing and printing #66
Comments
IMO:
|
@DKLoehr That's pretty much how I felt it should be settled. I think any case where we desugar, as with sets, is fine not to fix when printing since the AST is the same. For TGet and TSet, since for now at least I'm not doing any transformations on the network before printing it out, I don't see the need to change them to print as match statements for now, although it could be nice if we could allow lets with patterns like For dictionaries, I've gone ahead and written some draft code to change Additionally, I think there may be some small things I need to understand better about how the Printing module computes precedence, just to make sure I don't mix anything up, but I think that part is mostly handled. |
Change printing for operations to specify how the operation is printed in relation to its list of operands: either as a prefix, infix or circumfix (alternating between each operand, starting with an operand). Circumfix is only used by dict get and set for now. It's possible some precedence ordering may have been slightly altered by this change, but I have not had the chance yet to look through carefully, so this is something to watch for. Handles dict case of #66.
Currently, there are a few situations in which NV expressions are parsed in one way but printed in another (see #64 for an example of this that was previously reconciled). These include:
operations over tuples ((EDIT: set aside for now; we can reopen this issue if this becomes relevant)TGet
,TSet
: both not available at the user level, which is consistent with OCaml)MGet
:m[k]
versusm at k
,MSet
:m[k := v]
versusset(m,k,v)
)operations over sets ((EDIT: since the AST is the same, easier to leave these as-is)union
,inter
andminus
, which are all syntactic sugar forcombine
operations over dicts)Since NV typically doesn't need to print out any NV code to the user, this discrepancy is tolerable. However, these differences do mean that there are pain points for any tools that try to use a solution from NV (handled in #64) or that want to use NV's library to generate NV code (as in nvgen). Hence, it would be worthwhile to reconcile these differences by either adding new syntax, modifying printing to match syntax more closely, or both.
In cases where syntactic sugar is used, the discrepancies may be acceptable to leave as-is, as is the case for sets versus dicts. But other cases may be useful to have handled, particularly those for dicts.
The text was updated successfully, but these errors were encountered: