<div dir="ltr"><font face="courier new, monospace">False alarm - but thank you for making me spend time in the Macro Stepper - it was very enlightening !</font><div><font face="courier new, monospace"><br></font></div><div>
<font face="courier new, monospace">I am building a gui app that is wired-up/decoupled via messages dispatched through the event-space queue and I am using units to encapsulate the messaging end-points.</font></div><div>
<font face="courier new, monospace"><br>
</font></div><div><font face="courier new, monospace">The problematic code was</font></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace"><div>#lang racket</div><div><br>
</div><div>;; Manager for a particular frame</div><div>(require "../util/message-channel.rkt")</div><div>(require "messages.rkt")</div><div>(require "diagram-manager.rkt")</div><div>(provide frame-manager-for)</div>
<div><br></div><div>;; Make a frame manager and return the message channel unit for it</div><div>(define (frame-manager-for frame) </div><div> </div><div> ; new local message channel</div><div> (use-message-channel event-space-channel@) </div>
<div> </div><div> ; manager for the diagram itself</div><div> (use-message-channel (diagram-manager-for (send frame get-diagram-container))</div><div> as diag)</div><div> </div><div> (==></div>
<div> [(Show/Hide-Diagram) (diag<-- the-message)]) ; diag manager makes the canvas</div><div><br></div><div> (diag==></div><div> [(Diagram-Was-Shown) (send+ frame </div><div> (get-diagram-view-menu)</div>
<div> (set-label "Hide Diagram"))]</div><div> [(Diagram-Was-Hidden) (send+ frame </div><div> (get-diagram-view-menu)</div><div> (set-label "Show Diagram"))])</div>
<div> </div><div> (unit-from-context message-channel^))</div></font></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">The problem turned out to be that the diagram manager was sending Diagram-Was-Shown (a structure constructor) rather than (Diagram-Was-Shown), which made me believe that the (diag==> ...) form was not working. Anyway, I will make all the message structs extend a root message struct and check for that in the ==> macro to catch this in future.</font></div>
<div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">Thanks for the response !</font></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Aug 7, 2013 at 7:21 PM, Carl Eastlund <span dir="ltr"><<a href="mailto:cce@ccs.neu.edu" target="_blank">cce@ccs.neu.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div>Nick,<br><br></div>You can't just go by the immediate expansion. Lots of temporary names are bound by forms like define-values/invoke-unit; it binds an internal alias called msg-chan-subscribe that should be defined as a rename transformer for diagrammsg-chan-subscribe. Can you give a full example the rest of us can look at, and perhaps illustrate what incorrect runtime behavior is caused by this problem? That will be more telling than just the textual name from expansion, because identifiers carry a lot of "invisible" data about their bindings.<br>
</div><div class="gmail_extra"><br clear="all"><div>Carl Eastlund</div>
<br><br><div class="gmail_quote"><div><div class="h5">On Wed, Aug 7, 2013 at 10:00 PM, Nick Main <span dir="ltr"><<a href="mailto:david.nick.main@gmail.com" target="_blank">david.nick.main@gmail.com</a>></span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div><div class="h5">
<div dir="ltr"><font face="courier new, monospace">I have a signature that includes a macro to clean up the use of one of the procs in the signature.</font><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">Two different units with the same signature are used via define-values/invoke-unit - the second one uses a prefix in the export sig-spec to differentiate it from the first.</font></div>
<div><font face="courier new, monospace">The macro introduced by the second use does not refer to the other proc using the prefix.</font></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">The concrete example:</font></div>
<div><font face="courier new, monospace"><br></font></div><div><div><font face="courier new, monospace">;; Signature of a message channel</font></div><div><font face="courier new, monospace">(define-signature message-channel^</font></div>
<div><font face="courier new, monospace"> (</font></div><div><font face="courier new, monospace"> ;; ...</font></div><div><font face="courier new, monospace"> msg-chan-subscribe ; ( (msg -> boolean) first? -> thunk)</font></div>
<div><font face="courier new, monospace"> </font></div><div><font face="courier new, monospace"> ;; Enqueue message(s) for a channel at normal priority </font></div><div><font face="courier new, monospace"> <-- ; ( msg .. -> void )</font></div>
<div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace"> ;; Enqueue message(s) for a channel at high priority </font></div><div><font face="courier new, monospace"> <++ ; ( msg .. -> void )</font></div>
<div><font face="courier new, monospace"> </font></div><div><font face="courier new, monospace"> ;; Macro to create a message handler.</font></div><div><font face="courier new, monospace"> ;; ...</font></div><div>
<font face="courier new, monospace"> (define-syntaxes (==>)</font></div><div><font face="courier new, monospace"> (syntax-rules (msg)</font></div><div><font face="courier new, monospace"> [(_ match-body ...) (msg-chan-subscribe </font></div>
<div><font face="courier new, monospace"> (λ(msg) </font></div><div><font face="courier new, monospace"> (syntax-parameterize </font></div><div><font face="courier new, monospace"> ([the-message (make-rename-transformer #'msg)])</font></div>
<div><font face="courier new, monospace"> (match msg </font></div><div><font face="courier new, monospace"> match-body ...</font></div><div><font face="courier new, monospace"> [_ #t])))</font></div>
<div><font face="courier new, monospace"> #f)]))</font><span style="font-family:'courier new',monospace">))</span></div></div><div><span style="font-family:'courier new',monospace"><br>
</span></div><div><span style="font-family:'courier new',monospace"><br></span></div><div><span style="font-family:'courier new',monospace">When (</span><span style="font-family:'courier new',monospace">define-values/invoke-unit <some-unit> (import) (export (prefix diagram message-channel^))) is used it introduces the bindings diagram<-- , diagram<++ , diagrammsg-chan-subscribe and diagram==> .</span></div>
<div><span style="font-family:'courier new',monospace"><br></span></div><div><span style="font-family:'courier new',monospace">The form</span></div><div><font face="courier new, monospace"><br></font></div>
<div><font face="courier new, monospace">(diagram==></font></div><div><font face="courier new, monospace"> .. message handlers ..)</font></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">expands to (msg-chan-subscribe ...) rather than (</font><span style="font-family:'courier new',monospace">diagrammsg-chan-subscribe ...) - and thus it listens to the first (wrong) message channel.</span></div>
<div><span style="font-family:'courier new',monospace"><br></span></div><div><span style="font-family:'courier new',monospace">Is there any way to make macros defined in signatures be aware of the prefix used with the signature ?</span></div>
</div>
<br></div></div>____________________<br>
Racket Users list:<br>
<a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br></div></div>