-
Notifications
You must be signed in to change notification settings - Fork 14
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
Implement named arguments, Python-style #299
Comments
I hadn't realized it before, but you can send keyword arguments to The If we decide to allow |
I'm no longer on the fence; we should do it with the colon. Why? Becuase It's possible for #279 to come down in such a way that the direct ambiguity goes away, but (a) that is not at all certain, and (b) even if it did, there would still be some sort of mental ambiguity left. |
(And #279 came down in such a way that it'd be confusing to use |
I already started implementing this in a branch, but I hit an interesting snag, which I'll quickly describe: Macro calls are calls. As such, they have argument lists. It's in the argument lists we are adding the new named argument syntax. In other words, macro invocations get named arguments too. Fine. But one big way in which function invocation and macro invocation differ, is that the former takes evaluated arguments (that is, their Qtrees have been interpreted by the runtime), but the latter just wants the dry Qtrees as-is. The solution is probably (and I don't know if I realized this back then) to separate the "evaluate arguments" logic out to Need to try this. A bunch of language changes around constructors are blocking on this feature. |
That is, if you have a function
You could call it as (for example)
Python imposes the restriction that a positional argument never come after a named one. I suggest we do the same.
I'm slightly open to the objection that
=
is not the right syntax there, as it's not Perl-y enough. Perl 6 uses=
for parameter defaults, but usesy => "y"
or:y("y")
for named arguments. I suspect if you'd ask TimToady he'd say that it's "because it's not an assignment". Maybe in 007y: "y"
(like in object properties) would be the closest analogue. But I remain on the fence. (Update: Decided on colon; see below.)Shout-out to #112 and to the fact that I still haven't really started thinking about how a pluggable signature binder would need to work. 🎩 (Edit: Have now, in #329.)
The text was updated successfully, but these errors were encountered: