[Prev][Next][Index][Thread]
Q: Multidispatch semantic
-
To: info-dylan@ai.mit.edu
-
Subject: Q: Multidispatch semantic
-
From: "Samuele Pedroni" <pedroni@inf.ethz.ch>
-
Date: Fri, 13 Jul 2001 21:45:01 -0400 (EDT)
-
Organization: Swiss Federal Institute of Technology (ETHZ)
-
Xref: traf.lcs.mit.edu comp.lang.dylan:13476
Hi. I have tried the following program. After reading the DRM 6. Functions-
Method Dispatch I would have expected
some kind of ambiguity error, the results that I get with FunDev are just
like CLOS multidispatch. Argument order counts.
What I'm missing? Thanks Samuele Pedroni.
Module: hello2
define class <panel> (<object>)
end class <panel> ;
define class <pad-panel> (<panel>)
end class <pad-panel> ;
define class <specific> (<object>)
end class <specific> ;
define method present (panel :: <panel> , obj :: <object>)
format-out("generic panel present");
end method present;
define method present (panel :: <pad-panel>, obj :: <object> )
format-out("pad present");
end method present;
define method present (panel :: <panel> , obj :: <specific> )
format-out("generic panel <specific> present");
end method present;
define method present2 (obj :: <object> , panel :: <panel> )
format-out("generic panel present(2)");
end method present2;
define method present2 (obj :: <object> , panel :: <pad-panel> )
format-out("pad present(2)");
end method present2;
define method present2 (obj :: <specific> , panel :: <panel> )
format-out("generic panel <specific> present(2)");
end method present2;
define method main () => ()
let pad = make(<pad-panel>);
let obj = make(<specific>);
present(pad,obj) ;
format-out("\n");
present2(obj,pad) ;
end method main;
/* Output:
pad present
generic panel <specific> present(2)
given the rules in DRM 6. Functions - Method Dispatch
I would have expected an ambiguity error in both cases.
*/
begin
main();
end;
Follow-Ups: