by cnwsc2 >> Tue, 25 Mar 2003 1:00:39 GMT
There have been requests for an overload methods as a NFS and I wish to share my ideas on how it could be done in Jade to get feedback before adding as a NFS to Jade.
A method type would be created called a 'redirected' method which would be selected in a checkbox on the 'create new jade method' form.
To do this the 'method' class it would have a collection of other methods that it uses when redirecting the method which has an inverse to handle the deletion of the overloaded methods.
This collection would only be used by the 'redirected' method type.
The 'redirected' method would be set up by a redirector form where you add a methods from anywhere in the schema to the 'redirected' method.
This would also show what 'overloaded' methods are attached and their order of selection in this form as well.
When this method is invoked it would try in the order all the other methods in the
'redirector' overload methods collection getting the most correct parameters and return type.
It would first try to match by the parameters first , then the return type and finally there are more than one methods that match these criteria ,by the order of these methods in the collection.
Eg A redirected method called mDrawBox() has these methods as its overloaded methods
1)mDrawBox2(x : Integer , y : Integer);
2)mDrawBox3(xy : Integer);
3)mDrawBox4(xy : Integer, a :String);
4)mDrawBox5(xy :Integer): String
5)mDrawBox6(x :String)
When the Jade code executes mDrawBox(10) it would find that both (2) and (4) match the type of parameters.
Note (5) is not used because it needs a string type parameter.
Then it looks at the return type and finds that (2) matches the return type.
It would then attached the mDrawBox(xy) to the mDrawBox3(xy) method.
This would be easily to do when the F8 compiles the mDrawBox(10) method it would at that point set the reference of what method to invoke.
This redirector method would have no parameters and no return type and no jade code could be entered into the 'redirected' method but text could be enter into the method to document it.
All the redirector method purpose is to redirect what method is executed when it is invoked.
To support it the Ctrl 3 bubble help on the parameters for a method would cycle through the various overloaded methods attached to a 'redirector' method.
When creating these methods you would F-11 on the method to check what 'overloaded' method the ''redirected' method that it would invoke.
You thoughts and feedback