Skip to content
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 parameter defaults and slurpy parameters in 007 itself #259

Open
masak opened this issue Sep 20, 2017 · 1 comment
Open

Implement parameter defaults and slurpy parameters in 007 itself #259

masak opened this issue Sep 20, 2017 · 1 comment

Comments

@masak
Copy link
Owner

masak commented Sep 20, 2017

The original idea was that we'd be able to do this complete from the "outside", in userland, by providing a custom binder. (See #112.) That's still a possibility... but as a stepping stone we can simply model things in the implementation without exposing them in the language syntax, and then switching on the proper syntax in a 007-level module (which we can also fake as a pragma/flag initially).

I didn't include optional parameters in the list of things we should model, because when I think about it, an optional parameter is simply a parameter with a default None.

Also, worth keeping in mind that in the general case, a parameter default is a closure, not a value. The closure should close over the parameters declared so far.

Among the builtins,

  • prompt could benefit from having its msg parameter default to ""
  • substr could benefit from having its chars parameter default to self.chars
  • say could benefit — aw, that'd be nice! — from having a slurpy parameter

As part of this, we might want to finally separate a Parameter type from Q::Parameter, which is a bit misplaced in Sub, to be honest. (Cf #253.)

(I almost labeled this one "low-hanging fruit", but it might have unintended consequences, who knows.)

@masak
Copy link
Owner Author

masak commented Jul 15, 2018

I realize I would also like concat to be a builtin function (again), rather than a method on Array. The main reason is that I would prefer it to take a variable number of arrays (or rather iterables), and then it looks kind of lopsided to have it as a method on the first array.

Kthx.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant