-
Notifications
You must be signed in to change notification settings - Fork 161
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
Accessing list entries and record components of expressions #457
Comments
+1 :) |
With me its +2 now. Alexander
|
One reason this exists is because of the special casing of assignment (not saying we shouldn't get rid of that, but it's worth considering). Given |
It's not necessarily very difficult, but it's not simple. @ChrisJefferson has put his finger on the main issue -- where is := allowed in this more general world, and what does it mean? At present, any assignment begins with an identifier, and there is a special section of the parser that parses identifiers followed by arbitrary combinations of [] {} () . without knowing whether it's eventually going to hit a := or not. This would need to be torn up and rethought. |
@ChrisJefferson on wrote:
Yes, this should work. It is difficult to understand why
work, but
does not. @stevelinton wrote:
Ok, I hoped that you can identify the problem, since you have looked at the parser recently. Maybe these cases can be considered together with two more points on the old wish list (this first was already discussed in #40):
|
Another example while I am working through..
|
Just to pick up one of @frankluebeck's points: This was discussed as issue #37. The problem is that this syntax cannot always be disentangled from that for a permutation literal without an unfeasible amount of lookahead. In that issue we discussed a numbert of alternative syntaxes (is that the right plural) but reached no conclusion |
The first request turned out to be easier than I expected. A WIP pull request is at #462 2 (needs more testing, and shouldn't be done by cutting+pasting a chunk of code ). Any comments welcome. Very untested, beyond the examples on this page! Note this patch does not allow assignment to these new expressions. I think that the second request:
Would also not be difficult, however it could rapidly get complicated if people wanted anything deep (splitting multiple levels of list in particular). Copying the example at the top:
|
Well done. Am I right in thinking it simply doesn’t support any of the new syntax on the LHS of an assignment? — a good choice if so.
When this was discussed before people mentioned cases like y := [4,5,6]; At the end of this, what should x and y be? The only solution that I can see to be easy for GAP is to evaluate all the LHSs before the RHS so that y is [4,4,6] but I’m not sure that is what people would expect.
|
Yes. I looked at this a little this morning, and decided it's more horrible than I thought. For example (just to remind people), we parse
With regards the I briefly looked at if we could do So in short, implementing |
For what it's worth:
So, in sum, is there anything left to be done about this issue? If so, could somebody who knows please succinctly summarize it? Otherwise, let's close this. |
No response in the past month from @frankluebeck @ChrisJefferson or anybody else I am closing this now, feel free to reopen if you think anything in here is left to be done (but it might actually be better to open a new issue then). |
This recalls part of a very old wish list.
Would it be difficult to enhance the GAP parser such that list entries/components can be accessed in any expression that evaluates to a list/record (or positional/component object)?
And similarly for expressions evaluating to functions.
More precisely, it would be great if the follwing code examples would work in the obvlous way:
The text was updated successfully, but these errors were encountered: