2011/6/13 Stephan Houben <steph...@planet.nl>: > [...] > I have code like this which dispatches on > the type of a homogenous vector: > [...] > I was wondering if there is a more efficient way to > do this, one which doesn't involve a linear scan > over all possible types. I presume that at the C level > there is a "type tag" associated with any of these types; > is it possible to access this from the Racket level? > [...]
Hello Stephan, since everything can be interpreted as a structure in Racket, one thing you could do is dispatch on the name of structure types: (define (identify v) (case (vector-ref (struct->vector v) 0) ((struct:byte-string) "bytes") ((struct:u16vector) "small words") (else "whatever"))) However, whether this will really result in a performance gain I don't know. Ciao, Thomas -- When C++ is your hammer, every problem looks like your thumb. _________________________________________________ For list-related administrative tasks: http://lists.racket-lang.org/listinfo/users