[plt-scheme] structure inspectors

From: Robby Findler (robby at cs.uchicago.edu)
Date: Fri Jun 27 10:27:46 EDT 2003

Check out the macro make-->vector macro in (lib "macro.ss"
"framework"). It isn't documented, mostly because it doesn't belong
there. Anyways, you can write this:

  (define-struct s (a b c))
  (define s->vec (make-->vec s))

and s->vec is a function that turns `s's into vectors and you don't
need to worry about inspectors.

Robby

At Fri, 27 Jun 2003 10:24:16 -0400, "Mike T. Machenry" wrote:
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
> 
> I am having a problem testing programs that return structs. Currently I am
> creating a test-suite helper function for every struct that I define in the
> program that compares two values of that struct. This gets tiresome. equal?
> does not work without an inspector.
> 
> I tried writing a more powerful equal? for my test macro that would use
> struct->vector when struct? was true. Sadly struct? does not work without 
> an inspector. I then tried just changing all my structure definitions to have
> inspectors which was pretty nice, but I needed to change my code inorder to
> test it.
> 
> How do others solve this problem?
> What is the reasoning for having structs be an opaque, incomprable thing by
> default?
> 
> Thanks,
> -mike
> 



Posted on the users mailing list.