D - Multimethods
- Mark Evans (4/4) Feb 19 2003 http://nice.sourceforge.net/visitor.html
- Mark Evans (5/5) Mar 02 2003 This is the type system used in both Needle and Nice.
- Walter (4/7) Mar 07 2003 Do all the incarnations of a particular multimethod function all need to...
- Mark Evans (2/4) Mar 07 2003 What does that mean, 'done at once'?
- Walter (4/7) Mar 07 2003 be
- Mark Evans (37/42) Mar 07 2003 Off the top of my head, no. The (first-class) generic function has some...
- Dan Liebgold (5/5) Mar 10 2003 Correct me if I'm wrong, but aren't multimethod dispatch methods always ...
- Bill Cox (3/9) Mar 10 2003 That sounds right to me.
- Walter (5/10) Mar 10 2003 some
- yuqianzhou yahoo.co.uk (10/15) Mar 11 2003 Great! Walter, sounds like you're interested in implementing multimethod...
- Craig Black (14/14) Mar 24 2003 Hey peoples,
- Mike Wynn (3/12) Mar 24 2003 why not compile the binary tree into a set of cmps and jmps ?
- Craig Black (2/3) Mar 31 2003 Hmmm ..... sounds difficult to implement but a good idea!
- Ilya Minkov (3/6) Apr 09 2003 Why not optimise out all of the cmps and jmps altogether then. ;>
- Craig Black (8/14) Apr 10 2003 There is no way to "optimize out" the logic in the binary tree. It must
- Craig Black (2/2) Mar 31 2003 I was just thinking, you could also use a hash table.
http://nice.sourceforge.net/visitor.html Good advice from the Nice language, http://nice.sourceforge.net/index.html Mark
Feb 19 2003
This is the type system used in both Needle and Nice. Mark "On the integration of functional programming, class-based object-oriented programming, and multi-methods" http://www.exalead.com/Francois.Bourdoncle/mlsub.html
Mar 02 2003
"Mark Evans" <Mark_member pathlink.com> wrote in message news:b314qm$sns$1 digitaldaemon.com...http://nice.sourceforge.net/visitor.html Good advice from the Nice language, http://nice.sourceforge.net/index.htmlDo all the incarnations of a particular multimethod function all need to be done at once (like methods in a class, or members of a template)?
Mar 07 2003
Do all the incarnations of a particular multimethod function all need to be done at once (like methods in a class, or members of a template)?What does that mean, 'done at once'? Mark
Mar 07 2003
"Mark Evans" <Mark_member pathlink.com> wrote in message news:b4b6sq$2fpg$1 digitaldaemon.com...beDo all the incarnations of a particular multimethod function all need toAll be in the same scope, just like overloaded functions must be.done at once (like methods in a class, or members of a template)?What does that mean, 'done at once'?
Mar 07 2003
Walter says...Off the top of my head, no. The (first-class) generic function has some scope but the multimethods it 'owns' may live anywhere. It's just a question of how the call is dispatched. That determination is made by the ("multi") argument specializers and the design of the dispatch rules in the language. Those rules could be as wild as your imagination. Of course a major benefit of multimethods is that they can (should?) live outside class scope. This technique solves exactly Bill's problem of how to 'add members to multiple existing classes.' In terms of scope they might, e.g., live in several different modules, even if none of them are class members per se. Always subject to correction, Mark Possibly helpful links, and a quote: http://www.openbg.net/sto/newsread.php?grp=comp.lang.clos&msg=msg00246.html http://www.openbg.net/sto/newsread.php?grp=comp.lang.clos&msg=msg00244.html http://www.op59.net/cmm/cmm-0.15/users.html http://www.functionalobjects.com/resources/white-paper.phtml http://monday.sourceforge.net/wiki/index.php/MultiMethods http://www.cyberdyne-object-sys.com/oofaq2/body/basics.htm#S1.19 http://www.psg.com/~dlamkins/sl/chapter14.html http://www.cis.ohio-state.edu/~gb/Brew/Publications/HalfNHalf.pdf http://www.research.ibm.com/people/d/dgrove/papers/phd-thesis.pdf http://www.cs.washington.edu/homes/todd/research/ecoop99.ps 'In object-oriented languages with multimethods...the appropriate method to invoke for a message send can depend on the run-time class of any subset of the message arguments, rather than a distinguished receiver argument. Multimethods unify the otherwise distinct concepts of functions, methods, and static overloading, leading to a potentially simpler language. They also support safe covariant overriding in the face of subtype polymorphism, providing a natural solution to the "binary method" problem and a simple implementation of the "strategy" design pattern. Finally, multimethods allow clients to add new operations that dynamically dispatch on existing classes, supporting a form of what we call "open objects" ... that enables easy programming of the "visitor" design pattern and is a key element of aspect-oriented programming. Open objects also relieve the tension observed by others between ease of adding operations to existing classes and ease of adding subclasses.'All be in the same scope, just like overloaded functions must be.Do all the incarnations of a particular multimethod function all need to be done at once (like methods in a class, or members of a template)?What does that mean, 'done at once'?
Mar 07 2003
Correct me if I'm wrong, but aren't multimethod dispatch methods always some sort of runtime search at the time of the method call? Even if the search is optimized by the compiler (to a binary search or somesuch), doesn't this implementational requirement cross the line in terms of performance? Dan
Mar 10 2003
Dan Liebgold wrote:Correct me if I'm wrong, but aren't multimethod dispatch methods always some sort of runtime search at the time of the method call? Even if the search is optimized by the compiler (to a binary search or somesuch), doesn't this implementational requirement cross the line in terms of performance? DanThat sounds right to me. Bill
Mar 10 2003
"Dan Liebgold" <Dan_member pathlink.com> wrote in message news:b4ip35$ao7$1 digitaldaemon.com...Correct me if I'm wrong, but aren't multimethod dispatch methods alwayssomesort of runtime search at the time of the method call?Yes.Even if the search is optimized by the compiler (to a binary search or somesuch), doesn't this implementational requirement cross the line in terms of performance?It still should work out better than a sequence of if(dynamic_cast<...
Mar 10 2003
In article <b4jrb6$cvc$2 digitaldaemon.com>, Walter says...Great! Walter, sounds like you're interested in implementing multimethods in D? If you keep your minds open like this, I'm sure D will have a bright future! BTW, the following is what I wish to see before version 1.0: -- Object persistence: save/load objects to/from memory/disk/network. -- covariant (or anchored) type not just on function return type, but also on parameters: e.g. even without template, we can still write the correct deepCopy for any object as: like this deepCopy(like this anObj); (for anyone who read Eiffel, you know where I come from :-).Even if the search is optimized by the compiler (to a binary search or somesuch), doesn't this implementational requirement cross the line in terms of performance?It still should work out better than a sequence of if(dynamic_cast<...
Mar 11 2003
Hey peoples, I would like to thank Mark Evans for his numerous contributions to this mailing list. Multi-methods are great!! Implementation can be done in a number of ways. O(1) complexity can be achieved by indexing types and storing an N-Dimensional lookup table of function pointers. If the memory footprint for the N-Dimensional table gets to be too large, then you could store the function pointers in a binary tree. If multi-methods are implemented correctly, they will enhance performance, and save a lot of coding in many instances. Writing your own multiple-dispatch is a pain, and usually involves long switch statements (yuck)! I know from experience. Craig
Mar 24 2003
"Craig Black" <cblack ara.com> wrote in message news:b5o0du$iar$1 digitaldaemon.com...Hey peoples, I would like to thank Mark Evans for his numerous contributions to this mailing list. Multi-methods are great!! Implementation can be done in a number of ways. O(1) complexity can be achieved by indexing types and storing an N-Dimensional lookup table of function pointers. If the memory footprint for the N-Dimensional table gets to be too large, then you could store the function pointers in a binary tree.why not compile the binary tree into a set of cmps and jmps ?
Mar 24 2003
why not compile the binary tree into a set of cmps and jmps ?Hmmm ..... sounds difficult to implement but a good idea! Craig
Mar 31 2003
Craig Black wrote:Why not optimise out all of the cmps and jmps altogether then. ;> -i.why not compile the binary tree into a set of cmps and jmps ?Hmmm ..... sounds difficult to implement but a good idea!
Apr 09 2003
There is no way to "optimize out" the logic in the binary tree. It must exist in some form. Somehow, the multi-method dispatcher is going to have to find the method that corresponds to the identity of the objects it is dealing with. This can be done in a number of ways, none of which vaporize into thin air when you optimize them. Craig "Ilya Minkov" <midiclub 8ung.at> wrote in message news:b726ev$1ea5$1 digitaldaemon.com...Craig Black wrote:Why not optimise out all of the cmps and jmps altogether then. ;> -i.why not compile the binary tree into a set of cmps and jmps ?Hmmm ..... sounds difficult to implement but a good idea!
Apr 10 2003
I was just thinking, you could also use a hash table. Craig
Mar 31 2003