Lutz - feature request

Started by Jeff, May 30, 2008, 06:56:57 AM

Previous topic - Next topic

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
Jeff

=====

Old programmers don\'t die. They just parse on...



http://artfulcode.net\">Artful code

newBert

#1
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...
<r><I>>Bertrand<e></e></I> − <COLOR color=\"#808080\">><B>newLISP<e></e></B> v.10.7.6 64-bit <B>>on Linux<e></e></B> (<I>>Linux Mint 20.1<e></e></I>)<e></e></COLOR></r>

Jeff

#2
That works wonderfully.  Thank you!
Jeff

=====

Old programmers don\'t die. They just parse on...



http://artfulcode.net\">Artful code