digitalmars.D - Any news on multimethods?
- =?ISO-8859-1?Q?Jari-Matti_M=E4kel=E4?= (3/3) Oct 12 2006 About 1,5 year ago there was short discussion about native multimethods
- Bruno Medeiros (6/9) Oct 16 2006 What's wrong with the library approach? (and what multimethods library
- =?ISO-8859-1?Q?Jari-Matti_M=E4kel=E4?= (13/22) Oct 16 2006 Well, nothing in particular. It's just a bit more illustrative to use a
- Pragma (9/35) Oct 16 2006 That old thing? Template coding has grown by leaps and bounds since,
- Bruno Medeiros (31/57) Oct 18 2006 I made a simple and experimental multimethods(multiple dispatch
About 1,5 year ago there was short discussion about native multimethods in D on the NG. Well, is there any possibility to make them native on the language level. It's a bit annoying to use them via external libraries.
Oct 12 2006
Jari-Matti Mäkelä wrote:About 1,5 year ago there was short discussion about native multimethods in D on the NG. Well, is there any possibility to make them native on the language level. It's a bit annoying to use them via external libraries.What's wrong with the library approach? (and what multimethods library are you using?) -- Bruno Medeiros - MSc in CS/E student http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D
Oct 16 2006
Bruno Medeiros wrote:Jari-Matti Mäkelä wrote:Well, nothing in particular. It's just a bit more illustrative to use a syntax like void method(foo bar) { .. } and support multimethods on the language level without extra 3rd party wrappers. Of course it adds more bloat in general, but I don't really know what D is trying to be now. It's too heavy to be a system programming language (out of the box) and it lacks many high level features that are needed in large scale software projects. Double dispatch is a very primitive feature and multimethods are one possible way to implement it.About 1,5 year ago there was short discussion about native multimethods in D on the NG. Well, is there any possibility to make them native on the language level. It's a bit annoying to use them via external libraries.What's wrong with the library approach?(and what multimethods library are you using?)I was testing the old hack by Pragma. There was a newer version of it somewhere but my newsreader was not able to open it.
Oct 16 2006
Jari-Matti Mäkelä wrote:Bruno Medeiros wrote:That old thing? Template coding has grown by leaps and bounds since, and I'm sure there's a better version in the wild somewhere. There was also a discussion recently regarding "template varargs" or something similar for D. A feature like that would making writing a template multimethod library a piece of cake. IMO, having that support would almost be a fair trade-off for formal multimethods. -- - EricAnderton at yahooJari-Matti Mäkelä wrote:Well, nothing in particular. It's just a bit more illustrative to use a syntax like void method(foo bar) { .. } and support multimethods on the language level without extra 3rd party wrappers. Of course it adds more bloat in general, but I don't really know what D is trying to be now. It's too heavy to be a system programming language (out of the box) and it lacks many high level features that are needed in large scale software projects. Double dispatch is a very primitive feature and multimethods are one possible way to implement it.About 1,5 year ago there was short discussion about native multimethods in D on the NG. Well, is there any possibility to make them native on the language level. It's a bit annoying to use them via external libraries.What's wrong with the library approach?(and what multimethods library are you using?)I was testing the old hack by Pragma. There was a newer version of it somewhere but my newsreader was not able to open it.
Oct 16 2006
Jari-Matti Mäkelä wrote:Bruno Medeiros wrote:It is? I'm looking at that code segment and I have no ideia what it means.Jari-Matti Mäkelä wrote:Well, nothing in particular. It's just a bit more illustrative to use a syntax like void method(foo bar) { .. }About 1,5 year ago there was short discussion about native multimethods in D on the NG. Well, is there any possibility to make them native on the language level. It's a bit annoying to use them via external libraries.What's wrong with the library approach?and support multimethods on the language level without extra 3rd party wrappers. Of course it adds more bloat in general, but I don't really know what D is trying to be now. It's too heavy to be a system programming language (out of the box) and it lacks many high level features that are needed in large scale software projects. Double dispatch is a very primitive feature and multimethods are one possible way to implement it.I made a simple and experimental multimethods(multiple dispatch function) implementation not so long ago. It didn't work due to some DMD bugs (which have been fixed meanwhile) nor was it a complete implementation (I just wanted to see if and how it could be made), but the point is that it showed that a MDF implementation could be implemented library-side in a way almost (if not completely) as good as a in-language one. For reference here is how the user can use a MDF: // Define the MDF dispatcher MultiDispatchFunction!(bool function(Shape, Shape)) checkCollisionMDF; // Add dispatches: checkCollisionMDF.AddDispatch(&checkCollisionCC); checkCollisionMDF.AddDispatch(&checkCollisionCR); checkCollisionMDF.AddDispatch(&checkCollisionRC); checkCollisionMDF.AddDispatch(&checkCollisionRR); // Call: checkCollisionMDF.call(new Circle, new Circle); checkCollisionMDF.call(new Rect, new Rect); checkCollisionMDF.call(new Circle, new Rect); checkCollisionMDF.call(new Rect, new Circle); There is only one limitation: the MDF library has to have replicated code for each number of parameters of a MDF it wants to support, so the maximum number of parameters of the MDF function is arbitrarily limited. But other than that, (correct me If I'm wrong) isn't that usage as simple as possible, in fact, as simple as CLOS's multimethods? -- Bruno Medeiros - MSc in CS/E student http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D(and what multimethods library are you using?)I was testing the old hack by Pragma. There was a newer version of it somewhere but my newsreader was not able to open it.
Oct 18 2006