[plt-scheme] MrEd: Structure problem

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Sat Mar 31 13:13:53 EDT 2007

On Mar 31, 2007, at 1:08 PM, John Clements wrote:

> On Mar 31, 2007, at 5:29 AM, ela tataruch wrote:
>> Hi,
>> I'm making a project using MrEd which finished should allow  
>> drawing euclidian geometry. First, I thought of storing position  
>> of all my points in a list in order to be able to move points. But  
>> I realized that when I move points, figures which are drawn with  
>> them don't change. What I would need is something like pointers in  
>> C, so when one coordinates changes, all figures which use them,  
>> will change too. Does something similar exists in scheme?
> The feature you're looking for is called mutation; the ability to  
> make a change in one place which is visible in a bunch of other  
> places.  Yes, Scheme includes mutation. Take a look at boxes: box,  
> unbox, set-box!.  More generally, most structures can be mutated if  
> you want to.
> Be careful with mutation; because it gives you the power to  
> communicate between disparate pieces of code, it makes your code  
> harder to understand and harder to debug.

Perhaps ela is looking for a callback function that informs the view  
(canvas and drawing procs) when the model (the points) change. You  
could stay functional all the way if you so wish:


If you do want mutations, look at the examples in the manuals or the  
cookbook. -- Matthias

Posted on the users mailing list.