3 ms·
You can get a much more powerful alternative for "free" if you support de-structuring assignments (in arguments). JavaScript Example: function test({a,b,c
by chmod775 6y ago
You can get a much more powerful alternative for "free" if you support de-structuring assignments (in arguments).
JavaScript Example:
function test({a,b,c}) {
console.log(c,b,a)
};
test({
a: 1,
b: 2,
c: 3
});
If you have this there's really no need for named arguments anymore. If you add features to your de-structuring, your "named arguments" will have them too (things missing for JS specifically: optional objects, TS support to specify types for the destructured objects inline instead of repeating the entire thing).
- TekMol 6y agoIt is not more powerful. You cannot do this for example: function hello($name='Joe',$title='dear') { echo "Hello $title $name"; } hello('Sue'); Try here: https://3v4l.org/6MZHh https://3v4l.org/6MZHh With your object properties approach, you always have to use the variable "names".
- bmn__ 6y agoMixing implicit positional and named parameters is a misfeature. The named parameters should have a distinct syntax like other systems do, e.g. :$ twigil.