#220 closed enhancement (remind)
optional arguments in functions
Reported by: | imendez | Owned by: | danirus |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | Kernel | Version: | 1.1.2 |
Severity: | minor | Keywords: | |
Cc: |
Description
I think it would be a powerful imporvement the possibility of adding optional
arguments in functions.
I propose the brackets characters ('&?') to indicate that an argument is
optional, like in the functions descriptions.
For example, If I want to create a function with the same behaviour that "Round",
I will define:
Real Redondeo(Real numRed [, Real numDec = 0])
{
Real inv = numRed*(10numDec);
Real ent = Floor(inv);
Real mod = (inv)%ent;
Real red = numRed-mod/(10numDec);
red
};
where the argument 'numDec' is optional:
Real a = Redondeo(4.41);
Real b = Redondeo(4.41, 0);
Real c = Redondeo(4.41, 1);
Real d = Redondeo(4.41, 2);
In this example, 'a' and 'b' have the same value (4), 'c' yields 4.4 and 'd' returns
4.41.
Regards.
Change History (3)
comment:1 Changed 19 years ago by
Resolution: | → remind |
---|---|
Status: | new → closed |
comment:3 Changed 18 years ago by
bug_file_loc: | → http://www.tol-project.org |
---|
Fully agree but ensuring internal date syntax could be inefficient.