On Tuesday, March 26, 2013 06:36:46 PM Noah Lavine wrote: > Okay. I don't see a use for number 1. Could you explain why it's > important? It seems easier to me to just let each variable have its > own type. Actually it has it's uses. 1.
Note. This ideom aims at being a sound extension to the case where we have non boxed local variables that are never put into a closure and where we mutate them with lexical-set directly. Maybe that is easier to think of them this way. As you see this ideom will enable pretty fast execution of the code in the common case where the variable is never put in a closure. It will in the not uncommon case when you put a local variable inside a closure and return it and preserve the redo safe property. I didn't see that fluid-let could allow this as well through an optimization e.g. (let ((a 1)) code ...) redo safe and can be well optimized => (let (a) (fluid-let ((a 1)) code ...)) And it's actually better in many ways in that fluid-let guards the outer context of the variable to be changed. On the other hand, fluid-let does not mix well with delayed computations, my suggestion does so indeed. So Different notions, different benefit. But as you say thay are close to my number 2 suggestion > As for 2, I believe that's how MIT Scheme's (fluid-let ...) works. I > suspect that if you give up property 1, then fluid-let would do the > job you want. No, parameter values are stored in different dynamic state and because you have one dynamic state per thread usually (it's possible to let threads share dynamic-state) the concpet is safe with respect to multithreading. It does not look like fluid-let have that property. a) > Also, in the example you gave earlier (in your third email in this > thread, beginning with "you need to combine fluids and dynamic wind > ..."), I don't see the difference between set! and set~ semantics. b) >It > seems like the variables there have exactly the same semantics as > fluids, except that you don't have to use (fluid-ref ...) to get > their value. a) set! means that you will box a value. The coders intention is that it should behave as such. With set~ you will many times be able to unbox the value. But as you say, with the example it may look like they are the same. But note that putting a set! in the code means that the variables becomes unguarded and the with-undo-variables becomes a no-op. Really The whole setup is done in order to keep ~ semantic enclosed in a macro and the user of the macro should can work as if the macro only uses local variables with no set!. b) As I said, you are right that they are close in notion and many times the semantic will overlap but as described above they are different. /Stefan