-
-
Notifications
You must be signed in to change notification settings - Fork 647
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to get struct-type? #1783
Comments
> (struct s (v))
> (struct-info (s 0))
#f
#t
> |
Right, but you need a more powerful inspector:
The page @shhyou linked to explains inspectors: |
@bennn How do I change a defined structure? |
I'm not sure what you mean. Do you want to get the struct type of a struct that's defined in another file & doesn't use
then it'd be possible to use the saved inspector with |
If you're using a > (struct s (v) #:transparent)
> (struct-info (s 0))
#<struct-type:s>
#f If your struct isn't transparent, you probably shouldn't be reflecting over it with |
I'm implementing a DSL that needs to compare the two struct types. |
> (current-inspector (make-inspector))
> (struct x (a))
> (x 0)
#<x>
> (struct-info (x 0))
#f
#t
> |
@zaoqi Why not just use |
Or perhaps provide your own |
@shhyou Can I redifine |
Something like this (simply shadows the
|
(define (struct-type-eq? x y)
(let-values ([(tx _x) (struct-info x)] [(ty _y) (struct-info y)])
(equal? tx ty))) Can I define it like this? |
(struct-type-of v) → (or/c struct-type? #f)
Returns
#f
if(struct? v)
is#f
The text was updated successfully, but these errors were encountered: