Page 1 of 1

Lutz - feature request

Posted: Fri May 30, 2008 1:56 pm
by Jeff
Lutz,

Can we have a built-in function to give us the type of a value? Using cond with various predicates is *really* slow. Then we can do nice things like building type-case macros.

Thanks,

Jeff

Posted: Fri May 30, 2008 3:19 pm
by newBert
Does this simple function (without 'cond' and predicates) would not be sufficient?

Code: Select all

(define (type x)
  ; returns the type of data
  (let (types '("boolean" "boolean" "integer" "float" 
                "string" "symbol" "context"
                "primitive" "primitive" "primitive" 
                "quote" "list" "lambda" "macro" "array"))
       (types (& 0xf ((dump x) 1)))))
I don't know any more where I found it...

Posted: Fri May 30, 2008 5:04 pm
by Jeff
That works wonderfully. Thank you!