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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to