On Tue, 2006-07-11 at 00:35 -0700, Erick Tryzelaar wrote: > skaller wrote:
> I think we could do it if all our objects have the vtables, All our objects have *Felix* RTTI, which is much better than mere vtables and C++ typeinfo, because we can put any meta information we want into it. > I believe we can at link time statically determine a dispatch algorithm > for each multimethod. Furthermore, I believe at link time we can > determine if there are any missing multimethod functions, and emit a > warning/error, just like pattern matching. The only time this would > become an issue is if we end up dynamically loading modules that would > require changes to the dispatch tables, then they'd have to be > regenerated, and optionally rechecked for completeness. None of which is required for virtual function abstraction! The point is .. problems where method have covariant arguments need to use sums, not linear abstraction. What you want here is an open sum. There's already a need for a *particular* open sum: variable length arrays (which are an infinite sum of fixed length arrays of length n, for all n>=0) > Well it does in the same sense that destructuring via pattern matching > breaks encapsulation, It doesn't break encapsulation because variant destructors unravel concrete algebraic types, not abstract types: there's no abstraction there to break :) > just like the visitor pattern as well. You have to > do something if you have a binary problem, such as collision. Indeed .. use variants! You want it extensible? I can't be done! The point is it is *mathematically impossible*. There's no point even trying to do it, since it is provably impossible :) You can destructure a classification hierarchy .. but there's nothing OO in that, and the tree has to be closed and concrete. If you do that, and then switch to linear polymorphism (virtual functions) you have a hybrid solution: like using variants of classes in Ocaml. > It depends. Multimethods aren't appropriate for every situation, but > there are some cases when the classes are weakly interacting that it > becomes useful. Rather than Box2, consider say a heightfield. If we're > lazy, we could only implement collision between a heightfield and the > root shape object, and specialize it for, say, a wheel object to > implement better interaction. For most objects, basic collision is good > enough, but occasionally we need a little more for certain types. Yes. But the way to model this is with variants. The special objects are just variant cases .. and the general (default) objects are just another variant case whose argument is abstracted. It's a hybrid technique.. the point is you can already do this. There's no need for any special new constructions. In particular the set of 'special cases' must always be a closed set in the core library -- the default cases use virtual function dispatch and are open. > > How? Felix doesn't support any kind of subtyping: at best > > there are some coercions (throw out some fields of a record > > for example), but all that is handled at compile time. > > > > Oh, yeah, that could be added to the list. Wouldn't that be required if > we were going to add inheritance to our classes? For models of C++ class types, probably it is enough to add a dynamic cast .. there's already one in the library (although it might not be adequate). Adding coercions based on structural typing of Felix classes .. similarly to for records .. may be possible, but the coercions would always be static. Adding real virtual functions to Felix classes may fix this (that is, modelling methods by C++ virtual functions instead of ordinary C functions). > Thats awesome. When are you going to implement it? :) > > That would get rid of a lot of need for metaprogramming, but not all of > them. Actually Jay more or less claims it does get rid of *all* of them :) -- John Skaller <skaller at users dot sf dot net> Felix, successor to C++: http://felix.sf.net ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Felix-language mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/felix-language
