[plt-scheme] Native code generation and immutable pairs

From: Gregory Woodhouse (gregory.woodhouse at sbcglobal.net)
Date: Sun Feb 12 11:11:33 EST 2006

On Feb 12, 2006, at 5:28 AM, Noel Welsh wrote:

> The primary use in my experience is to simulate a mutable
> binding.  Module bindings can only be mutated by the
> defining module.  Sometimes it is useful to allow others to
> mutate a binding, in which case storing the value in a box
> is a solution.  However, it is almost always the wrong
> solution -- parameters are better for most use cases, and
> monads for pretty much all other cases I can think of,
> leaving boxes for the cases where you want inexplicable
> behaviour in the presence of concurrency and continuations.
> N.

Thanks. As I explained in my other response, I was rather surprised  
upon reading chapter 3 of SICP and seeing what could be done with  
pairs. I guess I had just tacitly assumed they were immutable (and  
didn't know about set-car! and set-cdr!) In practice, I've never used  
them, but have used define-struct, so I guess the real question is  
what I would do if I had to make do without define-struct. Off-hand,  
if I had neither mutable pairs nor the ability to create structures,  
it seems that I'd have to resort to building structures out of  
functions using message passing or some such.

I know it's audacious of me, but perhaps inspired by SICP, I've been  
hoping to implement an interpreter or compiler for at least an  
interesting subset of Scheme or another functional language, so I've  
been thinking about how all of this might go. The case of concurrency  
is of particular interest to me because I've been developing  
messaging applications (in MUMPS, not Scheme) for years, and have  
been intrigued by concurrency for years. I'm convinced that I don't  
understand continuations at all, but am reading PLAI and find it a  
very helpful (and interesting) text. The explanations in "Teach  
Yourself Scheme in Fixnum Days" and "The Seasoned Schemer" seem clear  
enough, but I just have this uneasy feeling that I don't understand  
what's going on.

Gregory Woodhouse
gregory.woodhouse at sbcglobal.net

"Doubt may be uncomfortable,
but certainty is absurd."  --Voltaire

Posted on the users mailing list.