Conversation
pymbolic/parser.py
Outdated
| # has a letter tag | ||
| pytools.lex.RE(r"[0-9]+([a-zA-Z]+)"), | ||
| # inf, nan | ||
| pytools.lex.RE("inf"), pytools.lex.RE("nan"), |
There was a problem hiding this comment.
This isn't quite what Python does. nan is the identifier, not a floating point number. I do agree that we want literals for these guys, but I'm not totally sure I like these. Python's float("nan") seems a bit out of character for (e.g.) loopy. Any other ideas?
There was a problem hiding this comment.
- The other possibility is to provide a namespace for such keywords, but that would violate
assert print(parse("inf")) == "inf"- We could also make the parser take a flag to treat these as keywords or otherwise.
There was a problem hiding this comment.
What's wrong with letting user code run a mapper to run symbol lookup on these things? I think in loopy lang we will ultimately want to allow from numpy import inf, to provide a principled way of accessing these things. (To be clear, I am only thinking of data and LoopKernel objects as being potentially importable.) But doing so would require loopy to remain in charge of symbol lookup.
I'm OK with adding a flag for the behavior you propose though.
ae1e657 to
d75b38e
Compare
d75b38e to
6761f86
Compare
No description provided.