-
Notifications
You must be signed in to change notification settings - Fork 12
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
Discussion around optional arguments to functions #60
Comments
One key difference between Ruby and Python vs HLB is that those languages already have support for maps and lists. So those optional arguments are data that can be passed around, splatted out with For example, given the following function:
A wrapper function may want to specify the
IMHO, the best syntax to use here combines the
|
Good point, I'm still erring on the side of avoiding composite data types in an effort to keep the language simpler but it may be a line we have to cross at some point. For now, I'll try to continue with basic types.
Which proposal are you talking about? In the
I like to idea of providing arbitrary options to pass through without manually copying up within each layer. I'm confused to the |
Right, but the consumer of
Yeah you'd need to define new syntax to provide for the composition of optionals. In other words, right now there is no way to refer to a functions optionals; either some data type for maps needs to exist, or some syntax to refer to optionals needs to exist. The For example, right now |
As we develop common modules in: https://github.com/openllb/modules
We want to expose as many knobs to ensure that it is reusable. However, at the same time we want to limit the number of required arguments so that you can invoke the module without being exposed to the full spectrum of options.
There's two approaches I've been thinking about:
Optional arguments
Starting with some implementations from some languages:
or
python
optional argumentsThe key features extracted from the examples is:
In HLB, this may look like:
Option signatures
Currently, builtin functions like
run
can take options that add optional behavior to a function. And you can define functions that wrap these builtin options too:User defined functions cannot have options, which makes for a odd experience. Here's some explorations into how we can make this work:
Idea 1
Idea 2
The text was updated successfully, but these errors were encountered: