[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Change/add symbol for omitted default arguments?
From: |
Judd Storrs |
Subject: |
Change/add symbol for omitted default arguments? |
Date: |
Wed, 28 Jul 2010 21:29:45 -0400 |
Octave allows default values for function arguments such as
function [a,b,c] = myfunc(d,e=3,f)
....
endfunction
When calling the function the default parameter can be used by entering the ":" symbol.
[a,b,c] = myfunc(3,:,5)
Recent versions of octave (and Matlab apparently) have adopted ~ to mark ignored output parameters. Given this change I think it would be congruous for the octave language to also adopt the ~ for omitted default input arguments.
[a,~,b] = myfunc(3,~,5)
An alternative would be to allow : to also mark ignored output parameters.
"~" carries the meaning of "not" in octave and seems semantically more correct than ":" which carries the meaning "all".
--judd
[According to comments on StackOverflow Matlab additionally uses ~ inside function declarations to mark positional parameters that are ignored by the function definition. I'm not entirely sure what this achieves due to the copy-on-write parameter passing except that perhaps Matlab may be able to skip evaluating the arguments. I don't think that particular optimization can play nice with octave's evaluation model which allows things like myfunc(3,f=myfunc2(g=5),5) with the second parameter marked ~ in the function definition]
- Change/add symbol for omitted default arguments?,
Judd Storrs <=