close Warning: Can't synchronize with repository "(default)" (/var/svn/tolp does not appear to be a Subversion repository.). Look in the Trac log for more information.

Opened 20 years ago

Closed 19 years ago

Last modified 18 years ago

#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/(10
numDec);
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 Víctor de Buen Remiro

Resolution: remind
Status: newclosed

Fully agree but ensuring internal date syntax could be inefficient.

comment:2 Changed 19 years ago by Víctor de Buen Remiro

Sorry, last message was for another bug.

comment:3 Changed 18 years ago by Víctor de Buen Remiro

bug_file_loc: http://www.tol-project.org
Note: See TracTickets for help on using tickets.