Re: [racket-users] Re-defined constant when dynamically evaluating module forms

2021-05-12 Thread Matthew Flatt
I think the problem here is that you're re-defining a module. The
`lifted/4` binding is probably a generated one in the module, and
redeclaring the module would require changing `lifted/4` --- and
probably other bindings that you would recognize, but `lifted/4`
happens to be hit first.

To avoid this kind of problem redeclaring a module, maybe you want a
fresh namespace every time, or maybe you want to parameterize `eval`
with `compile-enforce-module-constants` as #f so that redefinition is
allowed.

At Thu, 13 May 2021 02:40:44 +, Sage Gerard wrote:
> I have a program that takes a (trusted) module form as a list and then
> pulls out a provided value using this method. I used syntax/modread and
> generate a pseudorandom id for each value of `trusted` here.
> 
> (define-namespace-anchor anchor)
> (define module-namespace (namespace-anchor->namespace anchor))
> (define (add trusted)
>    (eval trusted module-namespace)
>    (dynamic-require `',(cadr trusted) 'data))
> 
> Full disclosure: I don't know how to do better. I figured that this
> wasn't the best way to do it to begin with because I get the following
> error under `raco test`'s runtime configuration.
> 
> define-values: assignment disallowed;
>   cannot re-define a constant
>    constant: lifted/4
>    in module:'pkgdef1620873248
> 
> I don't know what "lifted/4" is.
> 
> If I am bringing in module forms that I trust, what's the best way to
> dynamically evaluate them and pull out a provided value without running
> into that error?
> 
> --
> 
> ~slg
> 
> 
> -- 
> 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.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/e0a048c8-77ac-5126-5bef-226ecbe90
> 6dc%40sagegerard.com.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/20210512204617.0%40sirmail.smtps.cs.utah.edu.


[racket-users] Re-defined constant when dynamically evaluating module forms

2021-05-12 Thread Sage Gerard
I have a program that takes a (trusted) module form as a list and then
pulls out a provided value using this method. I used syntax/modread and
generate a pseudorandom id for each value of `trusted` here.

(define-namespace-anchor anchor)
(define module-namespace (namespace-anchor->namespace anchor))
(define (add trusted)
   (eval trusted module-namespace)
   (dynamic-require `',(cadr trusted) 'data))

Full disclosure: I don't know how to do better. I figured that this
wasn't the best way to do it to begin with because I get the following
error under `raco test`'s runtime configuration.

define-values: assignment disallowed;
  cannot re-define a constant
   constant: lifted/4
   in module:'pkgdef1620873248

I don't know what "lifted/4" is.

If I am bringing in module forms that I trust, what's the best way to
dynamically evaluate them and pull out a provided value without running
into that error?

--

~slg


-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/e0a048c8-77ac-5126-5bef-226ecbe906dc%40sagegerard.com.