> 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
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
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 :
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 ...)
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`
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
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 there a way to ask the type of a value without having to guess it first?
-- hendrik
--
You received this message because you are subscribed to
7 matches
Mail list logo