<div dir="ltr"><div>Even worse, I can't even reliably make identifiers that are unique with respect to bound-identifier=?, because marks don't survive marshaling any better than other "unique" values like internal definition contexts or uninterned symbols. I checked this by changing fresh to run generate-temporary and check.rkt to use bound-identifier=?.<br>
<br></div>The problem is pretty clearly that I'm using these identifiers without binding them to anything, and that's not what identifiers are for. I either need a way to actually bind these things to _something_, or I need to give up on identifiers for this purpose. So unless someone has a breakthrough and can solve this problem purely using identifiers, I'll look to other kinds of solutions for now.<br>
<div><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:20 AM, 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:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div><div>I'm having trouble creating identifiers that are unique with respect to free-identifier=? and that survive marshaling to compiled code. The normal source of fresh identifiers, generate-temporaries, only guarantees they are unique with respect to bound-identifier=?. The obvious alternative, gensym, does not properly survive marshaling -- copies saved in different .zo files load as distinct identifiers. I've tried a few alternative methods, none more successful than either of these.<br>
<br>Below, there are a few short files that show the difficulties and can be used to test other methods. The first, fresh.rkt, contains the procedure used to create fresh identifiers. The file original.rkt creates a fresh identifier at compile time. The file identical.rkt copies the identifier from original.rkt using quote-syntax. The file different.rkt creates another fresh identifier at compile time. The file check.rkt checks that the identifiers from original.rkt and identical.rkt are free-identifier=? to each other, and that the identifiers from original.rkt and different.rkt are not free-identifier=? to each other. To run a test, first update fresh.rkt to use the appropriate method for creating identifiers, then run "raco make check.rkt". Some of the methods work when simply running "racket check.rkt", but "raco make" marshals the identifiers to .zo files and exposes more problems.<br>
<br></div><div>Can anyone suggest an implementation that would work here?<br></div><br></div>;;;;; fresh.rkt<br><div>#lang racket<br>(begin-for-syntax<br> (require racket/syntax)<br> (define (fresh)<br></div><div> ;; does not guarantee free-identifier=?<br>
</div><div> #;(generate-temporary)<br></div><div> ;; does not survive marshaling<br></div><div> #;(gensym)<br></div><div> ;; also does not survive marshaling<br></div><div> (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></div><div>;;;;; 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></div><div>;;;;; 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></div><div>;;;;; 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></div><div>;;;;; 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 clear="all"><div>Carl Eastlund</div>
</div></div>
</blockquote></div><br></div></div></div></div></div>