Re: [racket] dispatch on type

2011-06-13 Thread Eli Barzilay
8 hours ago, Stephan Houben wrote: > I have code like this which dispatches on the type of a homogenous > vector: > > (define (gl-vector->type vec) >(cond > ((bytes? vec) GL_UNSIGNED_BYTE) > ((s8vector? vec) GL_BYTE) > ((u16vector? vec) GL_UNSIGNED_SHORT) > ((s16vector? vec

Re: [racket] dispatch on type

2011-06-13 Thread Jos Koot
lang.org] On Behalf Of Thomas Chust > Sent: 13 June 2011 17:11 > To: Stephan Houben > Cc: Racket Users > Subject: Re: [racket] dispatch on type > > 2011/6/13 Stephan Houben : > > [...] > > I have code like this which dispatches on > > the type of a homogenous vec

Re: [racket] dispatch on type

2011-06-13 Thread Thomas Chust
2011/6/13 Stephan Houben : > [...] > 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 "t

[racket] dispatch on type

2011-06-13 Thread Stephan Houben
Dear list, I have code like this which dispatches on the type of a homogenous vector: (define (gl-vector->type vec) (cond ((bytes? vec) GL_UNSIGNED_BYTE) ((s8vector? vec) GL_BYTE) ((u16vector? vec) GL_UNSIGNED_SHORT) ((s16vector? vec) GL_SHORT) ((u32vector? vec) GL_UNSIGNED