> On Jul 17, 2019, at 12:16 AM, Kevin Forchione <lyss...@gmail.com> wrote:
> 
> Hi guys,
> Is there any function in Racket that will return a symbol representation of a 
> value’s datatype? We can interrogate them with predicates, but it occurs to 
> me that this information must be carried in the object’s syntax somewhere… 
> otherwise the syntax->datum wouldn’t work. Of course I may be overlooking 
> something :) 

I'm not sure what you mean by "carried in the object's syntax" or why 
syntax->datum is relevant. Could you clarify with a concrete example?

Anyway putting aside the syntax part and only looking at values, the `describe` 
[1] package, in particular the `variant` [2] function might be helpful to you 
or not depending on what you mean by "datatype".

> (require describe)
> (variant 5)
'fixnum-integer
> (variant (expt 2 65))
'bignum-integer
> (variant 3.0)
'inexact-number
> (variant 'auu)
'symbol
> (variant "oee")
'string
> (variant (list 1 2 3))
'pair
> (variant (list))
'empty-list
> (variant (vector 1 2 3))
'vector
> (variant (λ (x) x))
'procedure

  [1]: https://docs.racket-lang.org/describe/index.html
  [2]: 
https://docs.racket-lang.org/describe/index.html#%28def._%28%28lib._describe%2Fmain..rkt%29._variant%29%29

> Kevin

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/F748A593-C3DA-42CE-935F-FD2100022C66%40knauth.org.
For more options, visit https://groups.google.com/d/optout.

Reply via email to