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
This feature request is continuing a discussion here: #2645 (comment)
I feel that the current way to define named arguments and give them defaults, could use some improvement, so I offer a proposal here to discuss some possibilities. I'd like it to work as close to ECMA as possible:
I know this precise syntax won't work in fish, but perhaps something like this:
function func -a x, y=0
return [x, y];
end;
I also thought about making required or optional explicit could be handy (and fish could offer automatic errors when the func is called without required params, eg:
function func --argument-required x --argument-optional y=0
return [x, y];
end;
func 1 2; // [1, 2]
func 1; // [1, 0]
func null 1; // [null,1] *does fish understand 'null'?
func; // error: argument x is required
Perhaps it could have a short-form like:
function func -ar x -ao y=0
return [x, y];
end;
-o and -r would be irrelevant if used without -a
I have zero experience with C code, so I doubt it is me to set up a dev and build environment to play with this, but I am very happy to discuss the details of how we may like the feature to function, and to come in contact with the project maintainers. I think Fish Shell seriously rocks, and I'm happy to help make it better.
The text was updated successfully, but these errors were encountered:
This feature request is continuing a discussion here:
#2645 (comment)
I feel that the current way to define named arguments and give them defaults, could use some improvement, so I offer a proposal here to discuss some possibilities. I'd like it to work as close to ECMA as possible:
11.1.1 Default parameter values
I know this precise syntax won't work in fish, but perhaps something like this:
I also thought about making required or optional explicit could be handy (and fish could offer automatic errors when the func is called without required params, eg:
Perhaps it could have a short-form like:
-o and -r would be irrelevant if used without -a
I have zero experience with C code, so I doubt it is me to set up a dev and build environment to play with this, but I am very happy to discuss the details of how we may like the feature to function, and to come in contact with the project maintainers. I think Fish Shell seriously rocks, and I'm happy to help make it better.
The text was updated successfully, but these errors were encountered: