[plt-scheme] MrEd: Structure problem
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.
John Clements
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2484 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20070331/16d583b4/attachment.p7s>