<div dir="ltr">Thanks, I'll look into that. It's implemented in the C code, but it looks like it's effectively doing a combination of generate-temporary and syntax-local-lift-module-end-declaration. I don't think it gives me the option of creating two fresh identifiers with the same printed name in the same module and have them be immediately unique via free-identifier=?, as the binding would not have taken effect yet, so to speak. This is one of those cases where my life would be so much easier if I could relax any one of the constraints I'm working under.<br>
</div><div class="gmail_extra"><br clear="all"><div>Carl Eastlund</div>
<br><br><div class="gmail_quote">On Fri, May 31, 2013 at 9:58 AM, Eric Dobson <span dir="ltr"><<a href="mailto:eric.n.dobson@gmail.com" target="_blank">eric.n.dobson@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
If you replace all of your internal definition manipulation with<br>
(syntax-local-lift-expression #'#f), it passes your check.rkt. You<br>
don't have control over the names, but I'm guessing you could look<br>
into the implementation and see what it is doing to generate such<br>
names.<br>
<div class="HOEnZb"><div class="h5"><br>
On Fri, May 31, 2013 at 8:32 AM, Carl Eastlund <<a href="mailto:cce@ccs.neu.edu">cce@ccs.neu.edu</a>> wrote:<br>
> I want a non-probabilistic guarantee of uniqueness, partly because I'd<br>
> rather not rely on something nondeterministic, and partly because in an<br>
> ideal solution, I'd like to have control over the printed names of these<br>
> identifiers.<br>
><br>
> Carl Eastlund<br>
><br>
> On Fri, May 31, 2013 at 9:27 AM, Eric Dobson <<a href="mailto:eric.n.dobson@gmail.com">eric.n.dobson@gmail.com</a>><br>
> wrote:<br>
>><br>
>> What does unique mean in this context? Does probabilistically unique<br>
>> work? If so could you form an identifier with the symbolic form<br>
>> "unique-id-"+UUID?<br>
>><br>
>> On Fri, May 31, 2013 at 8:20 AM, Carl Eastlund <<a href="mailto:cce@ccs.neu.edu">cce@ccs.neu.edu</a>> wrote:<br>
>> > I'm having trouble creating identifiers that are unique with respect to<br>
>> > free-identifier=? and that survive marshaling to compiled code. The<br>
>> > normal<br>
>> > source of fresh identifiers, generate-temporaries, only guarantees they<br>
>> > are<br>
>> > unique with respect to bound-identifier=?. The obvious alternative,<br>
>> > gensym,<br>
>> > does not properly survive marshaling -- copies saved in different .zo<br>
>> > files<br>
>> > load as distinct identifiers. I've tried a few alternative methods,<br>
>> > none<br>
>> > more successful than either of these.<br>
>> ><br>
>> > Below, there are a few short files that show the difficulties and can be<br>
>> > used to test other methods. The first, fresh.rkt, contains the<br>
>> > procedure<br>
>> > used to create fresh identifiers. The file original.rkt creates a fresh<br>
>> > identifier at compile time. The file identical.rkt copies the<br>
>> > identifier<br>
>> > from original.rkt using quote-syntax. The file different.rkt creates<br>
>> > another fresh identifier at compile time. The file check.rkt checks<br>
>> > that<br>
>> > the identifiers from original.rkt and identical.rkt are<br>
>> > free-identifier=? to<br>
>> > each other, and that the identifiers from original.rkt and different.rkt<br>
>> > are<br>
>> > not free-identifier=? to each other. To run a test, first update<br>
>> > fresh.rkt<br>
>> > to use the appropriate method for creating identifiers, then run "raco<br>
>> > make<br>
>> > check.rkt". Some of the methods work when simply running "racket<br>
>> > check.rkt", but "raco make" marshals the identifiers to .zo files and<br>
>> > exposes more problems.<br>
>> ><br>
>> > Can anyone suggest an implementation that would work here?<br>
>> ><br>
>> > ;;;;; fresh.rkt<br>
>> > #lang racket<br>
>> > (begin-for-syntax<br>
>> > (require racket/syntax)<br>
>> > (define (fresh)<br>
>> > ;; does not guarantee free-identifier=?<br>
>> > #;(generate-temporary)<br>
>> > ;; does not survive marshaling<br>
>> > #;(gensym)<br>
>> > ;; also does not survive marshaling<br>
>> > (begin<br>
>> > (define id0 (datum->syntax #false 'fresh))<br>
>> > (define ctx (syntax-local-make-definition-context))<br>
>> > (syntax-local-bind-syntaxes (list id0) #false ctx)<br>
>> > (internal-definition-context-seal ctx)<br>
>> > (internal-definition-context-apply ctx id0)))<br>
>> > (provide fresh))<br>
>> ><br>
>> > ;;;;; original.rkt<br>
>> > #lang racket<br>
>> > (require "fresh.rkt")<br>
>> > (define-syntax (macro stx)<br>
>> > (with-syntax {[name (fresh)]}<br>
>> > #'(begin-for-syntax<br>
>> > (define original (quote-syntax name))<br>
>> > (provide original))))<br>
>> > (macro)<br>
>> ><br>
>> > ;;;;; identical.rkt<br>
>> > #lang racket<br>
>> > (require "original.rkt")<br>
>> > (define-syntax (macro stx)<br>
>> > (with-syntax {[orig original]}<br>
>> > #'(begin-for-syntax<br>
>> > (define identical (quote-syntax orig))<br>
>> > (provide identical))))<br>
>> > (macro)<br>
>> ><br>
>> > ;;;;; different.rkt<br>
>> > #lang racket<br>
>> > (require "fresh.rkt")<br>
>> > (define-syntax (macro stx)<br>
>> > (with-syntax {[name (fresh)]}<br>
>> > #'(begin-for-syntax<br>
>> > (define different (quote-syntax name))<br>
>> > (provide different))))<br>
>> > (macro)<br>
>> ><br>
>> > ;;;;; check.rkt<br>
>> > #lang racket<br>
>> > (require "fresh.rkt" "original.rkt" "identical.rkt" "different.rkt")<br>
>> > (begin-for-syntax<br>
>> > (unless (free-identifier=? original identical)<br>
>> > (error 'fresh "~v != ~v\n" original identical))<br>
>> > (when (free-identifier=? original different)<br>
>> > (error 'fresh "~v == ~v\n" original different)))<br>
>> ><br>
>> > --<br>
>> > Carl Eastlund<br>
>> ><br>
>> > _________________________<br>
>> > Racket Developers list:<br>
>> > <a href="http://lists.racket-lang.org/dev" target="_blank">http://lists.racket-lang.org/dev</a><br>
>> ><br>
>><br>
><br>
<br>
</div></div></blockquote></div><br></div>