For the archives:

    https://github.com/racket/racket/pull/1309

I have added #:extra-id-name and tried to mimic the coding style.

In    (struct foo (bar) #:extra-id-name baz)
the struct information in the compile time variable foo
and baz will be shared.

In    (struct foo (bar) #:extra-id-name baz
                                 #:omit-define-syntaxes)
the information will only be stored in baz.

Example:

#lang racket
(provide (struct-out baz))

(struct foo (bar)
  #:transparent
  #:extra-id-name baz
  #:omit-define-syntaxes
  #:omit-define-values
  #:constructor-name Foo)

(define (foo x)
  (Foo 42))

(foo 42)

produces a struct  value containing 42.

Does the approach look reasonable?

/Jens Axel



2016-04-11 17:10 GMT+02:00 Matthew Flatt <[email protected]>:

> I can't think of a good alternative, and a way to provide a name for
> the static info sounds fine to me.
>
> At Sun, 10 Apr 2016 18:33:49 +0200, Jens Axel Søgaard wrote:
> > Ping.
> >
> > 2016-04-02 22:26 GMT+02:00 Jens Axel Søgaard <[email protected]>:
> >
> > > Consider this snippet from scribble/html/xml
> > >
> > > (provide make-element)
> > > (struct element (tag attrs body [cache #:auto #:mutable])
> > >   #:constructor-name make-element
> > >   #:transparent #:omit-define-syntaxes #:auto-value #f
> > >   #:property prop:procedure
> > >   (lambda (e)
> > >     (unless (element-cache e) (set-element-cache! e (element->output
> e)))
> > >     (element-cache e)))
> > >
> > > (provide element)
> > > (define (element tag . args)
> > >   (define-values [attrs body] (attributes+body args))
> > >   (make-element tag attrs body))
> > >
> > > I would like to provide the structure definition, but simply adding
> (provide
> > > (struct-out element)) does not work, since  element  is not bound to
> the
> > > structure id.
> > >
> > > An #:extra-id-name option for struct could solve this.
> > >
> > > Is there another way to provide the struct element without renaming the
> > > element function?
> > >
> > > /Jens Axel
> > >
> > >
> > >
> > >
> > >
> > > --
> > > --
> > > Jens Axel Søgaard
> > >
> > >
> >
> >
> > --
> > --
> > Jens Axel Søgaard
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Racket Developers" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to [email protected].
> > To post to this group, send email to [email protected].
> > To view this discussion on the web visit
> >
> https://groups.google.com/d/msgid/racket-dev/CABefVgwdePmoo556iL_%2BVj0d5_dpFux
> > Z-WR_bsP43nqVRhy_DQ%40mail.gmail.com.
> > For more options, visit https://groups.google.com/d/optout.
>



-- 
-- 
Jens Axel Søgaard

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-dev/CABefVgxUQ-PToCe4eDWDWE-vfqybFj9qO_EFQ6nWdWgvuC59hg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to