[racket] Shared and structs with #:auto
I like the design of Jay's sstruct, and I think we should take some of
its ideas for Racket's `struct` (or Racket2's).
https://github.com/jeapostrophe/exp/blob/master/sstruct.rkt
https://github.com/jeapostrophe/exp/blob/master/sstruct-tests.rkt
Vincent
At Tue, 29 Jul 2014 16:43:52 -0500,
Spencer Florence wrote:
>
> Woops. I was under the impression that #:auto worked like an optional
> argument. Is there any way to do optional constructor arguments with
> structs (I don't see one but I can hope...)?
>
>
> On Tue, Jul 29, 2014 at 4:39 PM, J. Ian Johnson <ianj at ccs.neu.edu> wrote:
>
> > From the struct docs:
> > constructor-id (which defaults to id), a constructor procedure that takes
> > m arguments and returns a new instance of the structure type, where m is
> > the number of fields that do not include an #:auto option.
> >
> > You don't give anything to the constructor for #:auto fields.
> > -Ian
> > ----- Original Message -----
> > From: "Spencer Florence" <florence at northwestern.edu>
> > To: "racket" <users at racket-lang.org>
> > Sent: Tuesday, July 29, 2014 5:32:46 PM GMT -05:00 US/Canada Eastern
> > Subject: [racket] Shared and structs with #:auto
> >
> >
> >
> > Hi all,
> >
> > I'm trying to use shared with a structure that has a field with #:auto
> >
> > If I have some structure like this:
> >
> >
> > (struct test ([a #:auto]) #:transparent #:mutable)
> >
> >
> >
> > this works fine:
> >
> >
> > (shared ([b (test)]) b)
> >
> >
> > but this errors:
> >
> >
> > (shared ([b (test 1)]) b)
> >
> > with "shared: wrong argument count for structure constructor; expected 0,
> > found 1 in: (test1 1)"
> >
> >
> > Is this a bug? Is there a work around?
> >
> > --Spencer
> > ____________________
> > Racket Users list:
> > http://lists.racket-lang.org/users
> >
> [1.2 <text/html; UTF-8 (quoted-printable)>]
>
> [2 <text/plain; us-ascii (7bit)>]
> ____________________
> Racket Users list:
> http://lists.racket-lang.org/users