On Thu, Apr 16, 2015 at 7:32 AM, Alexander D. Knauth <[email protected]> wrote: > > >>> On Apr 15, 2015, at 2:29 PM, Jon Zeppieri <[email protected]> wrote: >>> >>>> I'm trying to provide a struct, the struct type of which uses >>>> prop:procedure and prop:match-expander, and I'd like the procedure to >>>> have a contract. > > >>> On Apr 15, 2015, at 10:12 PM, Jon Zeppieri <[email protected]> wrote: >>> >>>> It's an instance of a struct. Here's the background: I have a struct >>>> type, created with `struct`, which has its own constructor and match >>>> expander. However, I don't want to use that constructor or match >>>> expander as part of the public interface. (The struct contains some >>>> fields that should be treated as private.) Now, the only way I know to >>>> provide a single identifier that can act as both a struct constructor >>>> and a match expander is to use a struct. So, in this case, I need to >>>> use a *different* struct type, an instance of which can be used, on >>>> one hand, as a procedure to construct an instance of the original >>>> struct type, and on the other, as a match expander (also for the >>>> original struct type). >>> >>> So If I understand correctly what you’re doing, you have a normal struct A, >>> at “runtime” with a transformer binding like normal structs have. >>> Then you have a compile-time struct B, which has prop:procedure and >>> prop:match-expander, where you want an instance of B to be the right-hand >>> side of a (define-syntax <identifier> (B ….))? Is that correct? And the >>> prop:procedure in B will expand to something like (A ….), and the >>> prop:match-expander in B will expand to (A ….) as a match pattern? Or am I >>> misunderstanding what you’re trying to do? > > > On Apr 15, 2015, at 11:02 PM, Jon Zeppieri <[email protected]> wrote: > >> You got it. > > So do you want to put a contract on the instance of B, or do you want to put > a contract on what it expands to?
What it expands to, with correct blame ascription. > > If you want to put it on what it expands to, then you could look at this: > http://docs.racket-lang.org/syntax/exprc.html > Or this: > http://docs.racket-lang.org/unstable/wrapc.html Thanks, I'll take a look. > > By the way, why wouldn’t you just use define-match-expander instead of > defining the B struct? > > Because I need the same identifier to expand either to a procedure or to a match expander, and I don't know how to do that using define-match-expander. -Jon -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.

