[plt-scheme] teachpacks, structures, and equality

From: ifconfig nslookup (configurator at gmail.com)
Date: Sun Sep 19 01:58:42 EDT 2004

[Sent to wrong address, apologies]

I believe, but am not sure, that you need to (define-struct mystruct
(field1 field2) (make-inspector)). This creates an inspector for that
struct, causing its fields to be publically visible or something like
that.

ifconfig

On Sat, 18 Sep 2004 21:35:38 -0400, Prabhakar Ragde
<plragde at uwaterloo.ca> wrote:
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
> 
> There is something I don't understand about teachpacks. I create one
> that says:
> 
>  (module test mzscheme
>    (provide (all-defined))
>    (define-struct mystruct (field1 field2))
>    )
> 
> and save it as test.ss in the teachpacks directory. Then I create the
> following file:
> 
>   (define myvar (make-mystruct 1 2))
>   (equal? myvar myvar)
>   (equal? myvar (make-mystruct 1 2))
>   (equal? (make-mystruct 1 2) (make-mystruct 1 2))
> 
> When I set the language to Beginning Student, load the test.ss
> teachpack, and run this, I get
> 
>   true
>   false
>   false
> 
> But if I replace "mystruct" with "posn", all three tests evaluate to
> true.
> 
> How do I get "equal?" to work with a structure defined in a teachpack?
> Many thanks. --PR
>


Posted on the users mailing list.