Nice multiple dispatch details
[email protected] Thu, 7 Feb 2008 20:09:21 +1300
| Newsgroups | gmane.comp.lang.nice.general |
|---|---|
| Message-ID | <[email protected]> |
Hi,
I have a few questions regarding the multiple dispatch mechanism in
Nice and how it compares to other languages (CLOS, Dylan, Cecil
etc.)
When calling a method, Nice, like other multiple dispatch languages,
has to chose the most appropriate method body from a set of
available definitions (based on the dynamic type of the supplied
arguments, of course).
What are the criteria of grouping method definitions into a "dispatch
set":
- the method's name (I assume)
- the package where the method is defined?
- the number of arguments?
- static types of arguments?
In other words....
* Example1:
package Car;
foo(Car a1, Motorcycle a2)
package Motorcycle;
foo(Motorcycle a1, Truck a2)
...will these methods be the same dispatch set?
* Example2:
foo(Car a1, Motorcycle a2)
foo(Car a1, Motorcycle a2, Truck a3)
...will these methods be in the same dispatch set?
* Example3:
abstract class Vehicle;
class Car extends Vehicle;
abstract class Person;
class Driver extends Person;
toString(Car a1) = (...);
toString(Driver a1) = (...);
void main(String[] args) {
let d = new Driver();
toString(d);
}
... will the 2 methods be in the same dispatch set? I.e. when calling
toString() with a Driver as an argument, will both method
definitions be considered at runtime? Or is the compiler able to
disambiguate these two, eliminating the need for dynamic dispatch
(in this particular case)?
...Thanks a lot!
Radu.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/