You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
it was originally based on the declare -n nameref mechanism, but it diverged, because that turned out to use too much dynamic scope. It would simplify the code to get rid of it.
Also I wanted to change proc p(:out) to proc p(out Ref), but maybe we don't need that
Originally I was going to cut scope and just have procs, and not funcs. So setref was sort of an "escape hatch"
But now we have builtin sub for e.g. ${.myproc arg1}, and I think functions can be recast in terms of that mechanism.
the stdout can be the return value (like elvish I think), AND it can be captured efficiently in process.
It will just have the normal f(x, y) syntax, with arguments passed on stdin and return values on stdout? This is different than "builtin sub" which only takes string arguments, which precludes \0 inside the strings, which we DO WANT.
Idea: functions defined on top of procs. Value semantics only!
proc myfunc {
msgpack read :args
msgpack write [[42, 'foo']] # return value
}
# defines an interface wrapper of the SAME NAME
# shopt --set type_assert can check them?
func myfunc(x Int, y Int) Int [msgpack]
So a func can wrap
a proc
an external process
corpocesses
Maybe a better block-like syntax:
func myfunc {
arg x Int "docstring"
arg y Int "docstring"
returns z List[Int] "docstring"
format = 'msgpack' # can be JSON too
# by default it wraps a proc of the same name
# how to make it wrap a process or coprocess?
command = %(foo.py myfunc)
command = %(coproc foo.py myfunc)
}
Another idea: types as lazy arg lists?
arg x [Int]
arg y [Int]
returns z [List[Int]] # unfortunately template arguments and lazy arg lists both use []
setref
is sort of a hack for "return values"declare -n
nameref mechanism, but it diverged, because that turned out to use too much dynamic scope. It would simplify the code to get rid of it.proc p(:out)
toproc p(out Ref)
, but maybe we don't need thatsetref
was sort of an "escape hatch"${.myproc arg1}
, and I think functions can be recast in terms of that mechanism.f(x, y)
syntax, with arguments passed on stdin and return values on stdout? This is different than "builtin sub" which only takes string arguments, which precludes\0
inside the strings, which we DO WANT.The text was updated successfully, but these errors were encountered: