<div dir="ltr">I want a non-probabilistic guarantee of uniqueness, partly because I'd rather not rely on something nondeterministic, and partly because in an ideal solution, I'd like to have control over the printed names of these identifiers.<br>
<div><div><div class="gmail_extra"><br clear="all"><div>Carl Eastlund</div>
<br><div class="gmail_quote">On Fri, May 31, 2013 at 9:27 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">
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>
<div><div class="h5"><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 normal<br>
> source of fresh identifiers, generate-temporaries, only guarantees they are<br>
> unique with respect to bound-identifier=?. The obvious alternative, gensym,<br>
> does not properly survive marshaling -- copies saved in different .zo files<br>
> load as distinct identifiers. I've tried a few alternative methods, 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 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 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 that<br>
> the identifiers from original.rkt and identical.rkt are free-identifier=? to<br>
> each other, and that the identifiers from original.rkt and different.rkt are<br>
> not free-identifier=? to each other. To run a test, first update fresh.rkt<br>
> to use the appropriate method for creating identifiers, then run "raco 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>
</div></div>> _________________________<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>
</blockquote></div><br></div></div></div></div>