[gambit-list] Generic functions with Gambit
Nathan Sorenson
takeoutweight at hotmail.com
Tue Mar 20 16:52:37 EDT 2012
I see you dispatch via cond:
> (define (type-identifier obj)
> (cond ((number? obj) 'number)
> ((string? obj) 'string)
> ((symbol? obj) 'symbol)
> ((boolean? obj) 'boolean)
> ((null? obj) 'null)
> ((pair? obj) 'pair)
> ((vector? obj) 'vector)
> ((procedure? obj) 'procedure)
> (else 'other)))
>
When I was writing the Clojure->Gambit polymorphic dispatch I reached
immediately for case and branched on the numerical value of the
type/subtype id assuming I'd get fast constant time dispatch. This
cond as you've written would be a linear search, would it not? Or is
Gambit able to see that these predicates can be dispatched to in
constant time via type tag info?
More information about the Gambit-list
mailing list