search for: comparabledict

Displaying 2 results from an estimated 2 matches for "comparabledict".

2009 Feb 18
2
[LLVMdev] Parametric polymorphism
...plies some kind of function associated with the > type in order to actually perform it... True, but I'm not worried about that; method tables are easy to add once type substitutions are allowed. Dropping down to a mythical low-level language that I call template C, we would have: struct ComparableDict<T> { bool (*equals)(T a, T b); bool (*leq)(T a, T b); bool (*geq)(T a, T b); } T max<T>(ComparableDict<T>* dict, T a, T b) { if ((*dict->geq)(a,b)) return a; else return b; } This mechanism duplicates the dictionary-passing used in Haskell type classes....
2009 Feb 18
0
[LLVMdev] Parametric polymorphism
...type polymorphism. Apologies if I'm getting terms mixed up. > > True, but I'm not worried about that; method tables are easy to add once type > substitutions are allowed. Dropping down to a mythical low-level language > that I call template C, we would have: > > struct ComparableDict<T> { > bool (*equals)(T a, T b); > bool (*leq)(T a, T b); > bool (*geq)(T a, T b); > } > > T max<T>(ComparableDict<T>* dict, T a, T b) { > if ((*dict->geq)(a,b)) return a; else return b; > } > What do the parametrized types give you th...