guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: redo-safe-variables and redo-safe-parameters


From: Stefan Israelsson Tampe
Subject: Re: redo-safe-variables and redo-safe-parameters
Date: Wed, 27 Mar 2013 14:22:00 +0100

On Wed, Mar 27, 2013 at 1:42 PM, Noah Lavine <address@hidden> wrote:
> Hello,
>
> Let me see if I understand the point of set! and set~. I think the goal is
> to have a variable that is redo-safe, except that if someone uses set~ on
> it, then it is not redo-safe. Is that right?

No that would be hard to reason about. set~ and (~ a) indicate that
you want to use it as a redo safe variable. set! and normal variable
reference and you will get normal behavior in user code.

> If so, I think a variable like that is too hard to think about. I really
> don't think they should be in the language.

I tried hard to make it possible to have it and as well be able to
reason about it. Without support in the line I suggest it will be hard
to reason about it. With it the hardness of the code will be optional.
Want to stay in old scheme, don't use ~ variants in user code. Need
the feature, use the ~ variants.

> If you want to make a redo-safe variable act like it's not redo-safe, you
> can use an explicit box. You do it like this:
>
> (redo-safe-variable ((a 1)) (set~ a (make-variable)) ...)
>
> Inside the ..., you don't set~ or set! a, you use variable-set!. That way,
> if you capture the dynamic state and restore it, it just resets to being the
> same box as it was before, which means that all of the dynamic states share
> the same variable object and the same value. I think this is what Guile
> would do for regular variables anyway - you just have to be explicit about
> it here.

Yeah that could be one thing to describe it, but I think that it's
much nicer to let the code behave as scheme when the user code it as
scheme as described above.


> Note: this is actually a large part of the reason why I think
> redo-safe-variables (or fluid-let variables) are a good idea. I saw a quote
> from Sussman (one of the creators of Scheme) once that said that he should
> have made Scheme with immutable variables and explicit boxes for mutable
> locations. I think this is a reasonable extension of that
> idea.

Yeah but current complexity comes from the need of boxes that can be restored or
not depending on context. But I fully agree with the statement above.

Anyway I'm constantly imporving and learning about this I will hack on
the speck, add more examples and motivation. We have barely touched
the deeper aspects of this constructs e.g.
the dynamic part of choosing when to store and when to not store.

Thanks for your engagement!

/Stefan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]