Philip McGrath writes:

> Alternatively, here is a little example of how you might define lambda-box:
>
> #lang racket
>
> (struct lambda-box ([proc #:mutable])
>   #:property prop:procedure
>   (make-keyword-procedure
>    (λ (kws kw-args this . by-pos-args)
>      (keyword-apply (lambda-box-proc this)
>                     kws
>                     kw-args
>                     by-pos-args))))
>
> (define f
>   (lambda-box (λ () 1)))
>
> (f)
>
> (set-lambda-box-proc! f (λ () 2))
>
> (f)

Thanks!  This is a very helpful.

I guess if used in combination with namespace-variable-value one could
extend or freshly define depending on whether or not things are
defined in (current-namespace).

> I guess my bigger question is whether making everything redefinable is
> really the best mechanism to achieve what you want. I would bet that, even
> in your example, you don't usually want to dynamically redefine cons or +.
> I think it would probably be better to be explicit about where you want to
> allow redefinition and where you want identifiers to refer to a specific
> binding.
>
> If I were thinking about "a multiplayer game … where you could change the
> world while players are in it without kicking them out," I might think
> about a current-world parameter that can be mutated and having certain
> functions consult the current-world. Using the class-based object system or
> racket/generic for the world value might be particularly suitable. (Of
> course, the details would depend on exactly what about the world you want
> to be able to change.)

It could be that there are per-instance ways to handle things.  I'm
partly coming from the perspective of other lisps where there's a very
*general purpose* option with a mutable toplevel.  It could be that in
various applications there may be a more *specific* options that are
better.  But a lot of my question is whether or not the general route
*can* be brought to Racket.  It looks like it can be, even if Racket
folks will in general not like it :)

> -Philip

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to