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 20 years ago

Last modified 18 years ago

#219 closed defect (fixed)

Creating more than one function with the same Name but with different Type

Reported by: danirus Owned by: danirus
Priority: normal Milestone:
Component: Kernel Version: head
Severity: normal Keywords:
Cc:

Description

Tol lets us create more than one function with the same name but with different
Type.
You can try this bug with this code:


Real func1 (Real p) { p };
Text func1 (Text p) { p };
Matrix func1 (Matrix p) { p };

But you can only use the first defined.

Change History (3)

comment:1 Changed 20 years ago by danirus

Status: newassigned

More example code.
One way trying to access those funcionts is:


Real func(Real p) { p };
Text func(Text p) { p };

Code fReal = FindCode("Real", "func");
Code fText = FindCode("Text", "func");

Real etwas1 = fReal(2);
Text etwas2 = fText("Hola");

The last sentence doesn't work.

We can consider the bug in two ways:

1- Tol doesn't let create those funcionts, or
2- Tol does let us call those functions.

comment:2 Changed 20 years ago by danirus

Resolution: fixed
Status: assignedclosed

Finally, this must be a new feature.
After getting a closer look in the code, Tol never let us create more than one
user function with the same name. Symbols Table hasn't that facility. Although
we could have ever thought that, because of the behavior of Tolbase. Then I've
assumed this bug as new feature to implement.
Now Tol give us "User Functions Overloading". What does it mean?
We can do:


Real func (Real param) { param };
Text func (Text param) { param };
Real a = func(12);
Text b = func("It Works!");

Both variables, "Real a" and "Text b", has their own respective values.
Some risky changes have been made in the very Tol core components, so we must
keep an eye on secondary effects. If you are using CVS Tol version, please keep
in contact for that.

Thanks, Daniel Rus

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.