-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Description
Written assuming "call-parens" proposal, and parens optional for no argument functions; not part of proposal, considered off-topic
Ideas:
- Declarations currently all start with keyword (
import,export), this makes function declarations more consistent. - Currently additional
binds (key value, key2 value2)syntax, this makes it more natural. - Currently binds syntax is optional and not part of function signatures, this enforces it.
- Solving common case where only output return register is desired, no need to have an unused function name.
cc @coryb @slushie @aaronlehmann @copperlight
fn simple() fs {
image("alpine")
}
fn named_return() (fs ret) {
image("alpine")
}
# By default, first return register returns value from stack.
fn additional_returns() (fs ret, fs output) (
image("alpine")
run("echo foo > /out/msg") with {
mount(scratch, "/out") as output
}
}
# Can be overridden to only produce side effect, otherwise `output` returns
# value from stack.
fn overridden_return() (fs output) {
image("alpine")
run("echo foo > /out/msg") with {
mount(scratch, "/out") as output
}
}
# Going back to example `additional_returns`, `main` and `output` are registers
# defined in the namespace of `additional_returns`.
#
# If multiple return registers are defined, calling without the operator (::)
# returns the first register.
fn output_of_additional_returns() {
additonal_returns::output
}
fn output_of_overridden_returns() {
overridden_return
}
# Using the more appropriate `<>` for subtypes
fn metatron() option<run> {
mount(fs {
local("${localEnv("HOME")}/.metatron")
}, "/run/metatron")
}
Metadata
Metadata
Assignees
Labels
No labels