1. Is this possible?
- Posted by murphy Jul 26, 2008
- 1021 views
function foo (object arg1, object arg2=0, object arg3=0}
Now, if you call foo() <- note: fewer than the 'required" # of args, you get an error
foo takes 3 arguments
foo()
Is it possible that the error message could be, instead:
foo requires 1..3 arguments
would make things easier, as you wouldn't have to go back & look up foo to determine if it really requires 3, or if it will be satisfied with 1.
2. Re: Is this possible?
- Posted by mic Jul 26, 2008
- 1044 views
You'd probably want to look it up anyway to see what KINDS of arguments it takes. But it's still a good idea I guess.
3. Re: Is this possible?
- Posted by CChris Jul 28, 2008
- 996 views
You'd probably want to look it up anyway to see what KINDS of arguments it takes. But it's still a good idea I guess.
Can do, but cannot commit to svn these days
CChris
4. Re: Is this possible?
- Posted by jeremy (admin) Jul 28, 2008
- 1044 views
Can do, but cannot commit to svn these days
Chris,
Is this because of your Internet down or are you still suffering from a 403 error since SF.net did their SVN upgrade? If that later is the case, you need to do a
svn switch relocate http://rapideuphoria.svn.sourceforge.net/svnroot/rapideuphoria/trunk https://rapideuphoria.svn.sourceforge.net/svnroot/rapideuphoria/trunk
Jeremy
5. Re: Is this possible?
- Posted by CChris Jul 28, 2008
- 994 views
You'd probably want to look it up anyway to see what KINDS of arguments it takes. But it's still a good idea I guess.
Can do, but cannot commit to svn these days
CChris
Hmm, not as clear cut as I thought.
The first non defaulted argument # is known, as well as the total number.
However, you could always code
function foo(integer n=0,integer p,integer q=2,integer r)
I'm not sure what the error message should be then. Perhaps recording the # of the last non defaulted parameter as well would be enough, not too difficult.
CChris
6. Re: Is this possible?
- Posted by CChris Jul 28, 2008
- 1017 views
Can do, but cannot commit to svn these days
Chris,
Is this because of your Internet down or are you still suffering from a 403 error since SF.net did their SVN upgrade? If that later is the case, you need to do a
svn switch relocate http://rapideuphoria.svn.sourceforge.net/svnroot/rapideuphoria/trunk https://rapideuphoria.svn.sourceforge.net/svnroot/rapideuphoria/trunk
Jeremy
No, it's the landline, I think I mentioned it in the private email with the zip filme with some files to commit. Hopefully it gets repaired this week.
For the arg # issue: what you can do now is the following:
You nneed to recompile, except if using eu.ex.
CChris
7. Re: Is this possible?
- Posted by SDPringle Jul 29, 2008
- 999 views
Is the following line CChris be equivalent to a 3.1 function definition since you'll need to supply a fourth argument or can optional arguments really be in the middle and beginning? Does the function foo(3,4) assign to p and r?
function foo(integer n=0,integer p,integer q=2,integer r)
The error should be foo requires at least 2 but at most 4 arguments.
8. Re: Is this possible?
- Posted by murphy Jul 29, 2008
- 953 views
Is the following line CChris be equivalent to a 3.1 function definition since you'll need to supply a fourth argument or can optional arguments really be in the middle and beginning? Does the function foo(3,4) assign to p and r?
function foo(integer n=0,integer p,integer q=2,integer r)
The error should be foo requires at least 2 but at most 4 arguments.
Actually, in the example you gave, I think it requires 3 (or 4) arguments, it's just that the first and third can be defaulted with a blank instead of a value: foo(39) (hope I typed that right) the results should be {0,3,2,9}
So the question is really how to word the message to give the most useful info in the least confusing way. Maybe something like "foo requires 4 parameters, (1 and 3 may be defaulted)"
9. Re: Is this possible?
- Posted by murphy Jul 29, 2008
- 952 views
looks like two commas together don't work, that should have read:
foo(,3,,9)
10. Re: Is this possible?
- Posted by CChris Jul 29, 2008
- 951 views
Is the following line CChris be equivalent to a 3.1 function definition since you'll need to supply a fourth argument or can optional arguments really be in the middle and beginning? Does the function foo(3,4) assign to p and r?
function foo(integer n=0,integer p,integer q=2,integer r)
The error should be foo requires at least 2 but at most 4 arguments.
foo(3,4) is illegal.
However:
?foo(,3,,4) -- is the same as ?foo(0,3,2,4)
While at first glance it may seem odd to put defaulted parameters in the midle as in the above eample, there are quite a few cases where it makes sense, in matrix or tensor calculations for example.
If the relative positions of your parameters don't critically matter, then you are better off putting mandatory params first, then defaulted. This avoids extra commas. But sometimes the order is critical, so the syntax is available.
I'm not sure he error message you suggest would be right either.
CChris
11. Re: Is this possible?
- Posted by DerekParnell (admin) Jul 29, 2008
- 935 views
foo(39) (hope I typed that right)
The double commas markup is used for subscripting text. You coded foo(,,3,,9) so the '3' got subscripted.
When typing in code fragments, it is better to use the <eucode> </eucode> tags, or the no-wiki tags {{{ }}} to display it inline.
eg.
The defaulted version would be foo(,,3,,9)
or
The defaulted version would be
foo(,,3,,9)