Re: [racket-users] ask the type of a value (partial solution)

2020-08-03 Thread Alexis King
> On Aug 3, 2020, at 11:48, Hendrik Boom wrote: > > Still, it would be nice to find out how to get this information more > directly instead of relying on functions that do much more than > what I was asking for. In general, there aren’t any. The ability of struct->vector to extract a

Re: [racket-users] ask the type of a value

2020-08-03 Thread Ryan Culpepper
but beware, for > (for-each (lambda (x) (printf "~a: ~a\n" (~v x #:min-width 28) (struct->vector x))) (list "hello" (let () (struct string (n)) (string 5 "hello" : #(struct:string ...) # : #(struct:string ...) Ryan On Mon, Aug 3, 2020

Re: [racket-users] ask the type of a value (partial solution)

2020-08-03 Thread Hendrik Boom
On Mon, Aug 03, 2020 at 05:06:51PM +0100, Laurent wrote: > and yet: > > > (for-each >(λ (x) (printf "~a: ~a\n" (~v x #:min-width 28) (struct->vector x))) >`(hello "hello" 43110 #f #(h e l l o) #"hello" (h e l l o) >,(new frame% [label ""]))) > > hello :

Re: [racket-users] ask the type of a value

2020-08-03 Thread Laurent
and yet: > (for-each (λ (x) (printf "~a: ~a\n" (~v x #:min-width 28) (struct->vector x))) `(hello "hello" 43110 #f #(h e l l o) #"hello" (h e l l o) ,(new frame% [label ""]))) hello : #(struct:symbol ...) "hello" : #(struct:string ...)

Re: [racket-users] ask the type of a value

2020-08-03 Thread Alexis King
In general, the answer is “no,” mostly because it’s not clear in Racket what “the type of a value” means. It’s difficult to come up with a definition that would be useful enough to satisfy your criterion of not “having to guess it first.” Consider: suppose you had a hypothetical `type-of`

Re: [racket-users] ask the type of a value

2020-08-03 Thread Laurent
Maybe try `struct->vector`, which works on any value iirc (from mobile, can't test) On Mon, Aug 3, 2020, 15:19 Hendrik Boom wrote: > In plain, untyped Racket: > > It is possible to ask if a value is a symbol with symbol? > It is possible to ask if a value is a string with string? > etc. > > Is