alias of a fn: allow function alias
(coerce trailing arguments into an array) -> not sure why this is needed with the inbuilds. feat:
alias cmd = _cmd_fn
where RHS _cmd_fn
is a fn
with the semantics that cmd args...
calls _cmd_fn args...
while coercing trailing args into an array.
Alternatively, a new keyword other than the existing alias
keyword could be used.
This would be non-breaking syntactic sugar. It would allow you to do for example:
fn _f arg1 trailing:[str]
...
end
alias f = _f
f arg1
f arg1 arg2
f arg1 arg2 arg3
...
which would call:
_f arg1 []
_f arg1 [ arg2 ]
_f arg1 [ arg2 arg3 ]
The use case is exposing commands for which typing the []
is prohibitive. For example, to use zoxide with ion, the best that can be currently done as far as I can tell is z [ dirname ]
, which is not ergonomic enough for a command that needs to be very fast to type, since its purpose is to be a faster more convenient cd
. This would allow z dirname
.
This comes up in other issues like #952 (closed).
This proposal is aiming at the same use case as #834, without changing fn
or let
definitions. Instead, the proposed alias would just be syntactic sugar that avoids requiring the brackets. (Supporting functions with variadic args would make fn
definitions more complicated and less clear.)
bash/dash/zsh/fish all allow functions to have variable numbers of arguments.