-
Notifications
You must be signed in to change notification settings - Fork 24
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
Multiplication and division in Proposal A #42
Comments
I agree that multiplication and division seem a bit out of place and open an enticing door. It's already hard enough to verify that something isn't Turing-complete for safety purposes. Any operation that adds choice or change makes it more likely that unintended completeness will be achieved. |
@jchesterpivotal Perhaps that particular horse has already bolted since JSONPath filters include logical expressions. See accidentally Turing complete. |
Even now Turing's ghost taunts us. It's enough to drive a man to Church. |
Full agree here. The TODO part I think points to the fact that Proposal A does return a valid response (an empty list) instead of Hi @jchesterpivotal, thanks for chiming in! |
Thanks @glyn, please keep those issues coming! |
…ons in filter expressions. '-' is actually part of the path. #42
Hmmm, I'm not convinced, for three reasons. Firstly, the same would then have to apply to
Going back to
whereas Jayway fails to parse the path with That said, the above could be handled using bracket child notation which presumably should accept arithmetic operators. Secondly, it seems somewhat arbitrary to reject just the basic four arithmetic operators. Thirdly, limiting the check to these four operators effectively acknowledges the existence of implementations which support these operators, but not of other implementations with a broader set of operators. |
Yes, I see the problem here. Maybe this one is best tackled by not looking at the consensus too strictly, but come up with a good reasoning to which characters are allowed, and which ones are not (and why, of course). The initial Regex was trying to exclude characters that would interfere with the existing parsing rules, but then I felt being too generous was making it harder for future additions to the syntax. |
+1
I have precisely the same feeling and yet JSON is pretty permissive. Thankfully, we have bracket child notation as a fall-back if we end up being a bit too restrictive on the dot child front. I would have liked to keep the child name syntax uniform between bracket child and dot child, but I've come to realise this is unrealistic and that the bracket child notation was almost certainly introduced precisely to support a broader character set in child names. As you observe, it's easier to relax restrictions in future than to tighten them up, so as long as we don't rule out a big chunk of current usages, we can probably be pretty restrictive. How about starting with identifier syntax? |
We have a consensus in non-ASCII symbols, so we should probably start from supporting Unicode. And Unicode has a good standard for identifiers: https://unicode.org/reports/tr31/ |
I have something like this in my implementation's lexer for a NAME token, for example:
|
That's amazing @remorhaz I've applied this locally to the Proposal A's grammar without your modifications to the two classes:
This will fail some of the queries:
|
+1 |
See EcmaScript identifier description for an example. They combine UnicodeLetter non-terminal (combined of several Unicode properties) with some selected ASCII chars to construct their own IdentifierStart. We can do the same using either ID_Start/ID_Continue properties or using another property set. In fact, the latter could be better because JsonPath "identifiers" are not exactly what identifiers are in most languages. My point is just using any Unicode properties we need if possible instead of inveniting our own character sets from scratch. |
Following on from the idea of only allowing some kind of identifier as a dotted child name:
The child names like We might be able to allow leading digits so that But I don't see how we can allow Also, I don't see how we can allow Not sure about |
Do note that in the current implementation of Proposal A, |
There's no consensus on it, though it's not difficult to implement and I'd rather vote for it. |
I feel we should try to allow all common identifier patterns found across the programming languages that currently implement JSONPath (if that's possible without overlapping with syntax elements too much). |
Maybe it's worth trying to use |
Sounds reasonable if |
No, it doesn't. We should add any additional symbols explicitly to the symbol class, like |
What's important to know about Unicode standard describes identifiers in the following way:
In JsonPath we probably don't need to restrict the first symbol, so we can just consider identifier as "non-empty sequence of letters, ideographs, digits, uderscores AND
|
Maybe we should instead define a simple set of characters which are not allowed in an identifier, like |
That approach would allow letters, which according to a comment above:
|
But maybe that's not a great problem. The more I think, the more I agree that we should avoid Unicode properties in standard. I know what I'm talking about - I have implemented Unicode properties manually and the solution includes seeking ~600 ranges of symbols (which may require pre-building a b-tree index!) Mongolian letters and cuneiform poorly fit in strings, too; yet JSON allows them and no one seems to suffer. |
This approach leads us to |
Which definition of |
The classic |
I really like the idea of keeping this simple rather than introducing a "cottage industry" of identifier parsing. But I suspect that omitting |
Well, adding |
I agree the alternative of using spaces to separate math operators and identifiers isn't desirable. So there is a choice between allowing I guess Proposal A could go with @cburgmer How would you like to play this? Should Proposal A try to lead the standard or follow it later? |
This will break existing consensus on allowing non-ASCII symbols in dot-child. |
Proposal A lists multiplication and division as "to dos". I'm nervous that this is the start of scripting and once these operations are introduced, the proposal may be drawn into implementing some not particularly well scoped subset of JavaScript.
Can we instead agree that scripting is out of scope and drop multiplication and division? If not, how/where do we draw the line?
The text was updated successfully, but these errors were encountered: