On Tue, Feb 12, 2019 at 11:43 AM Shu-Hung You
<shu-hung....@eecs.northwestern.edu> wrote:
>
> On Tue, Feb 12, 2019 at 10:04 AM David Storrs <david.sto...@gmail.com> wrote:
> >
> > Could someone point me to the FM on how to properly use struct-info?
> > For the life of me, I cannot get anything except (values #f #t) out of
> > it.  I see that:
> >
> > 1) struct-info only works with struct types that are under the control
> > of the current inspector.
> >
> > 2) You can provide an inspector to a struct declaration, but it will
> > be placed under the control of the **parent** of what you passed it,
> > not the actual thing you passed it.  This breaks my brain.
> >
>
> The inspector used at struct type creation time needs to be controlled
> by the current inspector so you can obtain reflective information.
> That is, the inspector used at struct type creation time is a
> sub(-sub-sub-...) inspector of the current inspector.
>
> #lang racket/base
>
> (require racket/struct-info)
>
> (define old-insp (current-inspector))
> (define insp (make-inspector))
>
> (current-inspector insp)
> (struct S (field1 field2))
> (current-inspector old-insp)
>
> (define s
>   (S 5 'hi))
>
> (struct-info s) ;;=> ok
>
> (current-inspector insp)
> (struct-info s) ;;=> #f #t

Thank you for the explanation.  Can I ask why the heck it works this
way?  This seems to be explicitly designed for maximal surprise and
minimal usefulness.


>
>
> > --
> > 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.
> > For more options, visit https://groups.google.com/d/optout.

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to