5 ms·
Could you clarify if you are trying to make a comparison between garbage collection and unique_ptr? Or are you saying that you wish CLOS allowed dispatch on ty
by GregBuchholz 10y ago
Could you clarify if you are trying to make a comparison between garbage collection and unique_ptr? Or are you saying that you wish CLOS allowed dispatch on types as well as classes (anyone know the historical reason for why this is the case?). Or are you making the point that it would be ugly to create a new class "vector-of-list-of-fixnums"? Or something else?
- catnaroek 10y agoIt has nothing to do with garbage collection. I could've used GHC Haskell with sufficient extensions (MultiParamTypeClasses, FlexibleInstances, perhaps UndecidableInstances too) enabled as an example, instead of C++. The point is that C++ has a much richer type structure on which you can dispatch.
- jorams 10y agoCLOS only allows dispatch on classes and not types, because there is no hierarchy in types. For example, if you have a method specializing on the type (satisfies a) and a method specializing on the type (satisfies b), and you call a generic function with an object that satisfies both a and b, which method should be called first? Or methods specializing on the types (integer 0 8) and (integer 1 9). If the argument is 5, which type is more specific? Classes are a subset of types with a certain hierarchy, so there is always a "correct" order for methods to be called in.