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
Now it's getting interesting. Because we first need to figure out how we want to be able to declare a function.
I've let go of the idea to be bash-compatible, i.e. I do understand why fish shell decided to deviate here and there.
I very much like the way of how F# declares a function as well as strong typing. I think it might make sense to embrace strong typing in a shell as well. Even bash kind-of(?) does know about whether it deals with ints (for arithmetic) for example. Going explicit with types should improve readability and maintainability of scripts as well.
Syntax proposal by example:
// Define function f, receiving 3 string parameters, and returning one stringletf(a,b,c):str =
echo "a: $a, b: $b, c: $c"return"($a,$b,$c)"lety= f "foo"3.1415 $VAR // prints and returns something into $y
echo $y // prints "(foo,3.1415,VALUE)"letg a b:str =
echo "a is: $a, and b is: $b"if a = b thenreturn"same"elsereturn"not same"lethas_var name:bool =return(getenv $name)!=""// single-line function definitionlethas_var name:bool =(getenv $name)!=""
The text was updated successfully, but these errors were encountered:
Also, nice addition would be to have creation in-place for example during piping, something like find -name "*.cpp" | cat $1 cp $1 path/$1 would cat files and copy them
Now it's getting interesting. Because we first need to figure out how we want to be able to declare a function.
I've let go of the idea to be bash-compatible, i.e. I do understand why fish shell decided to deviate here and there.
I very much like the way of how F# declares a function as well as strong typing. I think it might make sense to embrace strong typing in a shell as well. Even bash kind-of(?) does know about whether it deals with ints (for arithmetic) for example. Going explicit with types should improve readability and maintainability of scripts as well.
Syntax proposal by example:
The text was updated successfully, but these errors were encountered: