Re: Identifier equality of identifiers stashed in preserved syntax properties

Alexis King <[email protected]>
Newsgroups gmane.comp.lang.racket.user,gmane.lisp.scheme.plt
Message-ID <[email protected]>
As a small followup to this, I managed to come up with the following
hacky workaround, which seems to be working alright so far.
Specifically, it’s a function that converts arbitrary preservable values
into expressions that evaluate to themselves:

  (define preservable-property->expression
    (match-lambda
      [(and (app prefab-struct-key (? values prefab-key))
            (app struct->vector (vector _ fields ...)))
       #`(make-prefab-struct
          (quote #,prefab-key)
          #,@(map preservable-property->expression fields))]
      [(? list? lst)
       #`(list #,@(map preservable-property->expression lst))]
      [(cons a b)
       #`(cons #,(preservable-property->expression a)
               #,(preservable-property->expression b))]
      [(? syntax? stx)
       #`(quote-syntax #,stx)]
      [(and (or (? boolean?) (? symbol?) (? number?) (? char?)
                (? string?) (? bytes?) (? regexp?))
            datum)
       #`(quote #,datum)]
      [other
       (error
        'preservable-property->expression
        "disallowed value within preserved syntax property\n  value: ~e"
        other)]))

(That doesn’t currently handle all cases, like boxes/vectors/hash maps,
but it would be easy enough to extend.)

This is obviously a total hack, but it seems to work alright for this
particular case, and I thought I’d share it in case anyone else runs
into the same problem and this is helpful for them, too.

-- 
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 racket-users+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
For more options, visit https://groups.google.com/d/optout.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.