[racket-dev] relationship between define-struct and struct

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Mon Aug 30 18:35:15 EDT 2010

I've fixed `define-struct' in *SL to omit a reference to the
non-existent `struct:....' binding, so `struct-out' now works with the
definitions.

The error message from `struct-out' is also fixed to say "binding"
instead of "import".

At Sat, 28 Aug 2010 16:15:26 -0600, Jay McCarthy wrote:
> The student languages have a completely separate implementation of
> define-struct from Racket.
> 
> [lang/private/teach.rkt: do-define-struct: line 716
> 
> For a reason unknown to me, the struct type descriptor [line 805]
> returned by make-struct-type does not get defined (although it does
> check to make sure it could be defined.) [line 931]
> 
> I'm not entirely sure why this is although I anticipate that is has to
> do with the fact that such a value has no worth in *SL, because there
> are no operations on it. Thus it would be very awkward in the docs to
> say that a thing is defined with define-struct that has no meaning to
> students.
> 
> Since struct-out expects this thing to be defined, it errors. It is a
> bit awkward that the error suggests that it should have been imported,
> rather than defined in the file.
> 
> Jay
> 
> On Sat, Aug 28, 2010 at 1:23 PM, Shriram Krishnamurthi <sk at cs.brown.edu> wrote:
> > What is the relationship between define-struct and struct in Racket
> > 5.0.1?  By define-struct I mean the construct provided in ASL.  In my
> > custom language I have
> >
> > (define-struct tv (tag value))
> > (provide (struct-out tv))
> >
> > and I get the error
> >
> > struct-out: no import for structure-type identifier in: struct:tv
> >
> > Is this because define-struct suppresses the struct:tv "structure-type
> > information"?  (If so, why?)  ((And if so, is there a way to make
> > struct-out work shy of copying the implementation of define-struct and
> > adding/removing the line that hides this?))
> >
> > Shriram
> > _________________________________________________
> >  For list-related administrative tasks:
> >  http://lists.racket-lang.org/listinfo/dev
> >
> 
> 
> 
> -- 
> Jay McCarthy <jay at cs.byu.edu>
> Assistant Professor / Brigham Young University
> http://teammccarthy.org/jay
> 
> "The glory of God is Intelligence" - D&C 93
> _________________________________________________
>   For list-related administrative tasks:
>   http://lists.racket-lang.org/listinfo/dev


Posted on the dev mailing list.