-
Notifications
You must be signed in to change notification settings - Fork 15
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
Introduce a Tuple type #274
Comments
C parsers are truly a sight for sore eyes... |
Tuples are the obvious thing we should get back when we introspect a parameter list of a function or macro. Another nice thing about tuples is that we can hash on them; still undecided on exactly how hashing should work for things like dicts and sets. |
I for one wouldn't mind a
And later, when we can destructure over tuples, even better:
(And, with #281, we get rid of those pesky |
I was curious what Python does with
In 007 I think we should support Python 3 avoids this problem, however:
You get an iterator back, which you then have to either iterate directly, or explicitly cast to whatever sequence you want. This is the first time I'm impressed rather than annoyed by Python 3's "you always get iterators back" tendency. But it remains to be seen whether we copy Python 3's design, or just return back the same type we got. |
Python has one, and for good reasons. It's a sequential type whose values can't be modified after creation.
Syntax:
Parsing-wise, we don't know when we see the opening
(
whether we'll get aQ::Term::Tuple
or aQ::Group
. But that's no problem; we can just provisionally assume everything's the former and a comma-separated list of<EXPR>
with trailing commas allowed — and if all we find is a single element and no trailing comma, we downgrade it to the latter.From the Python language reference:
And here is the parser source, which seems to also work like that, at least when I squint.
We also don't have
Q::Group
yet. I think it's time to add it; a number of other issues hint that we should have one. The implementation ofQ::Group
would be very transparent and essentially just delegate to its contained node. The projected value is that language extenders might be able to hang semantics off of it.The text was updated successfully, but these errors were encountered: