-
Notifications
You must be signed in to change notification settings - Fork 176
New variadic arguments implementation #391
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
Conversation
|
Just for the record, two slightly alternative syntax variants were discussed, namely using or All variants are similarly easy to implement. My (not very strong) order of preference is Also notable is the fact that we now support different names for the variadic argument list, i.e. works, and |
|
I would favour the x[] syntax as being more obviously related to concepts already in GAP, rather than concepts from Python or C++. |
|
My order of preferences would be:
I like My second choice wins over my third choice because The last one has also a nice point though: the brain may expand |
|
For what it's worth (i.e. my two Eurocents, give or take :) ), I favor the |
|
My two cents: I favor |
|
As I mentioned before, I will not stand in the way of any choice that is made. |
|
@alex-konovalov wrote:
That is actually one of the reasons why I dislike it: It gives the incorrect impression that this is about marking an argument as receiving a list; but this is just a byproduct, after all, other arguments may also receive lists. The true intent here is to mark the argument as one receiving extra variadic arguments... In particular, I am concerned that it might mislead people with experiences in other languages which have similar Now, there are of course lots of other people who are not familiar with either notation, and thus would not find either more or less confusing. I believe most users would in fact be rather neutral about the choice of syntax. So, I have a group of users for which I also still don't get why you are concerned about people "cutting" their code accidentally. If that happens, you are always screwed. Moreover, I actually don't understand your specific example: if I botch a copy & paste of as and then adding |
|
Well, perhaps if someone uses coding style and cuts dots, then one could still get a valid input. But I've never seen such. I am not fixated on this at all - I think this is something to take into account only if you have two choices which seem absolutely identical otherwise. You can not predict all ways to shoot yourself in a foot in advance. As I said, I will be happy with any of three choices. Seems to me like we are leaning towards |
|
Here is another (weak) reason why I personally prefer or as synonym for which I would find highly useful. Of course we could still do that, even if we do not use but that would then be ambiguous for the parser, and feels contrived. |
|
I start leaning towards |
|
And I start leaning towards BTW, one should check readability of the code both WITH spaces and WITHOUT spaces. To help you compare all six options suggested so far: and |
|
Please vote: details at https://mail.gap-system.org/pipermail/gap/2015-December/000356.html |
|
Looking at the poll so far, it seems that "x..." is the clear "winner" so far. @ChrisJefferson would you mind rewriting this PR to use that syntax? |
src/read.c
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The indention here is different from the surrounding code (which seems to mix tabs and spaces). I think it is best to match the indenting mode of the surrounding code, to keep the code readable. For now, that is (we can fix the indention globally later on, perhaps during GAP days).
4e61aff to
f28d526
Compare
|
Hopefully now cleaned up. In the end, x... was the clear winner, so gone with that. Removed No documentation yet. |
|
Did you change the (few) examples of function (x, arg) that I had already put in? If not I can. Steve
|
|
Yup (although I just noticed there was a couple in the docs, so I'm doing that now). |
|
One consequence of this that we MUST do a second 4.8 beta |
|
Thanks
|
5a7fa84 to
452ccee
Compare
|
I think if @fingolfin is happy with this, we should go ahead and merge, and get the next beta out so we can do 4.8. |
doc/ref/language.xml
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing a full stop here.
doc/ref/language.xml
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sentence is weird in the revised form... It doesn't really make sense to only talk about the "single argument" case here, right?
lib/function.g
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turns out this check can fail: Apparently is possible for nams to be fail, when looking at C level code. The resulting function, when printed, is shown like this:
function ( <<arg-1>> )
<<kernel or compiled code>>
end
A reproducible (but not yet minimal) test case:
METHODS_OPERATION(Socle,1);
452ccee to
16d628d
Compare
16d628d to
f351e06
Compare
|
Now updated, with @fingolfin 's many comments fixed. The problem of printing functions without argument lists is fixed, but not in the .tst files (as I didn't track down a small function for testing yet). |
New variadic arguments implementation
|
Good job, Chris, thanks! |
|
The diffs below occur in the test of manual examples - I will fix this: |
* commit '2ee33a75ae033755b6fce81551bf7c5ffc1594e1': Updated index entries for arg and Argument Added /:=, Fix to List(Filtered construct Make `Filtered' and `List(Filtered' its own parsed unit Parse `Filtered' construct. Translate ` as record component. <...> as list. Further function names. Declare second argument as IsObject as IsInt is not yet available Updated examples changed after PR gap-system#410 Fixed examples after PR gap-system#391 improve auto generated manual example test files, add some auto-generated files to .gitignore Properly translate `elif' even if parse tree uses `else if' Facilty to translate function names to GAP equivalents Remove extern/gmp-5.0.5.tar.gz Better match list for `?Random` Remove arg representing variadic arguments in function lists, except when it is the only argument Add ... style varargs with tests and documentation Build GMP with C++ support enabled
Changes the notation for variadic argument lists from
(a,b,arg)(where arg is a special name) to(a,b, ...p)(wherepcan be any identifier, includingarg). This doesn't change functionality at all, it just means that we don't break any code which was usingargas an argument name.This patch leaves the older (new) notation in for now, if we like this I'll remove it and fix the standard library.
For the curious, after all this stuff is finished, all GAP 4.7 code will behave identically, this will only add new notation.