[racket-dev] question on scribble/eval's do-plain-eval on bytes and strings

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Mon Apr 2 17:34:30 EDT 2012

At Thu, 29 Mar 2012 11:25:37 -0400, Danny Yoo wrote:
> I've traced the source of this "begin" down to the do-plain-eval
> function in scribble/eval.rkt.
> 
>              ;; within do-plain-eval:
>              (cond [(syntax? s)
>                     (syntax-case s (module)
>                       [(module . _rest) (syntax->datum s)]
>                       [_else s])]
>                    [(bytes? s) `(begin ,s)]
>                    [(string? s) `(begin ,s)]
>                    [else s]))))
> 
> I assume it's trying to make sure than an evaluator defined by
> racket/sandbox doesn't treat it as program source rather than as data,
> since the sandbox treats strings and bytes in a special way.
> 
> Would it be equivalent behavior to turn the datum into a syntax object
> instead?  That is:
> 
>              ;; within do-plain-eval:
>              (cond [(syntax? s)
>                     (syntax-case s (module)
>                       [(module . _rest) (syntax->datum s)]
>                       [_else s])]
>                    [(bytes? s) (datum->syntax #f s)]
>                    [(string? s) (datum->syntax #f s)]
>                    [else s]))))
> 
> If this looks right, I can send as a patch.

I'm not completely certain, but that looks ok to me.


Posted on the dev mailing list.