-
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
Enhanced list indexing #192
Conversation
… bit of old commented out code relating to the equivalent change for access some time ago.
Moreover, - use of IS_POS_INTOBJ in multiple places for readability and efficiency - enforce consistent behavior for ELM/ASS/ISB/UNB, and also between interpreted and compiled code: positive integers as before, while anything else (including non-positive integers) is sent through method dispatch - some code cleanup (indention, uniform whitespace in comments, etc.)
This provides parser interpreter and coder support for multi-index access to lists At the moment all such accesses are translated into calls to ELM_LIST with a single argument which is a plain list of the indices, but there is kernel support for a fast-path for two arguments later if one is needed. At this stage printing of coded expressions, assignment, IsBound and Unbind are all to do, as are nested list accesses. l[...][x,y].
Really nice, thanks. Regarding tests: I guess that would involve Anyway: I got a crash in the testsuite with this branch:
|
Yes, testing will need a little care. Can we safely assume that no one will run tests hundreds of times in the same copy of GAP? If so I can create a new filter to install methods on inside the tests. Thanks for the crash report. I'll try LoadAllPackages(). The crash looks to be related to the partial variadic stuff rather than this, but maybe I've accidentally broken the error handling. |
It may or may not be related. I do get those warnings in master, too, of course, but not the crash. I did not yet try to track down what happens, just thought I should report it. |
Here is a small test case to trigger the crash:
|
Thanks I’ll get into it. S
|
Tests pass now, and this looks pretty good overall. One minor remark: The test checks whether functions using the new construct are printed correctly. But it only tests the multi-integer-index variant, i.e. |
I believe this is ready to merge |
Changes Unknown when pulling f447fc1 on stevelinton:sl/multi-index into ** on gap-system:master**. |
This is a cleaned up and rebased version of two old pull requests #83 and #28 (Thanks to @fingolfin and @markuspf for fixing the mess I'd made). It extends support for indexing into lists using indexes other than positive small integers. All such indexing ends up with GAP-level methods. It also adds the syntax l[i1,i2,....] which is mapped to l[[i1,i2,...]]. There is infrastructure in the kernel to allow for fast methods for the case of two indices (without creating the length 2 list) but this is currently not exported to GAP level.
Tests and documentation are still needed.