newLISP Fan Club

Forum => Anything else we might add? => Topic started by: Jeff on May 30, 2008, 06:56:57 AM

Title: Lutz - feature request
Post by: Jeff on May 30, 2008, 06:56:57 AM
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
Title:
Post by: newBert on May 30, 2008, 08:19:25 AM
Does this simple function (without 'cond' and  predicates) would not be sufficient?


(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...
Title:
Post by: Jeff on May 30, 2008, 10:04:04 AM
That works wonderfully.  Thank you!