Lutz - feature request

For the Compleat Fan
Locked
Jeff
Posts: 604
Joined: Sat Apr 07, 2007 2:23 pm
Location: Ohio
Contact:

Lutz - feature request

Post 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
Jeff
=====
Old programmers don't die. They just parse on...

Artful code

newBert
Posts: 156
Joined: Fri Oct 28, 2005 5:33 pm
Location: France

Post 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...
BertrandnewLISP v.10.7.6 64-bit on Linux (Linux Mint 20.1)

Jeff
Posts: 604
Joined: Sat Apr 07, 2007 2:23 pm
Location: Ohio
Contact:

Post by Jeff »

That works wonderfully. Thank you!
Jeff
=====
Old programmers don't die. They just parse on...

Artful code

Locked