This is something I wonder as well... given that internally Scheme *does know* about the type of a value, why isn't there a function that expose the information? Type-based dispatching is after all a legitimate development technique.
<br><br>Thanks,<br>yinso <br><br><div><span class="gmail_quote">On 6/10/07, <b class="gmail_sendername">Jos Koot</b> <<a href="mailto:jos.koot@telefonica.net">jos.koot@telefonica.net</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>----- Original Message -----<br>From: "Robert Nikander" <<a href="mailto:nikander@nc.rr.com">nikander@nc.rr.com</a>><br>To: "PLT Scheme List" <<a href="mailto:plt-scheme@list.cs.brown.edu">
plt-scheme@list.cs.brown.edu</a>><br>Sent: Sunday, June 10, 2007 6:28 PM<br>Subject: [plt-scheme] (typeof obj)<br><br><br>> Is there a way to get a type-name symbol or type object for any scheme<br>> object?<br>
<br>Of course there is a way, but you may not like it:<br><br>(define (types-of x) (filter identity (map (lambda (predicate typename) (and<br>(predicate x) type-name)) predicates type-names)))<br>(define predicates (list integer? procedure?, etc)
<br>(define type-names '(integer procedure, etc))<br><br>Of course the procedure returns a list of types, for a 1 is an integer, a<br>rational, a real and a complex number.<br>You also can think of adapting procedure make-struct-type, such as to add their
<br>predicates and names to the lists.<br>Same for define-struct, let-struct ...<br>Same for classes.<br><br>If you want only one type returned in stead of a list, two conditions must be<br>met:<br>First: for every two types A and B either A and B disjunct or A a subset of B or
<br>B a subset of A.<br>Second: carefully compose the lists of predicates and their names.<br>Jos Koot<br><br>><br>> (type 1) => 'integer<br>><br>> or<br>><br>> (type 1) => #<type integer>
<br>> (type (type x)) => #<type type><br>><br>><br>> Rob<br>> _________________________________________________<br>> For list-related administrative tasks:<br>> <a href="http://list.cs.brown.edu/mailman/listinfo/plt-scheme">
http://list.cs.brown.edu/mailman/listinfo/plt-scheme</a><br>><br><br>_________________________________________________<br> For list-related administrative tasks:<br> <a href="http://list.cs.brown.edu/mailman/listinfo/plt-scheme">
http://list.cs.brown.edu/mailman/listinfo/plt-scheme</a><br></blockquote></div><br>