guile-user
[Top][All Lists]
Advanced

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

Re: References/locations


From: Maciek Godek
Subject: Re: References/locations
Date: Mon, 18 Aug 2008 10:09:50 +0200

Clinton Ebadi:

>> I've been thinking of implementing this "location" stuff
>> as a smob, but you've got the point that it is (probably)
>> impossible to implement the location system without
>> redefining set! and define.
>
> You may want to read a few documents on functional programming to see
> why your locations concept is not good. There are a number of
> additional issues as well: one that comes to mind is the interaction
> of the garbage collector with pointers into the middle of a vector.

That's what I wanted to hear :)
(The other thing is the ambiguity: if we create a location to another
variable, say (set! y (location x)), then we can't redefine the meaning
of y easily:
(set! y 5) ; sets x to 5, which is unexpected behavior of set!
I think there would be many many more disadvantages)

> What is so wrong with forms like `(set! (vector-ref foo index) ...)'?

In scheme the only problem is that they don't work, unless we
redefine vector-ref:
(define vector-get vector-ref)
(define vector-ref (make-procedure-with-setter vector-get vector-set!))

> It's generally bad practice to go around destructively modifying data
> structures anyway.

Perhaps I'm not an experienced lisper, but I'd rather say it's generally
a bad practice to generalize overly: everything depends on what you're
doing. I'm currently working on an object system that is based on a local
state and it would be a stubbornness to implement it using purely
functional paradigm.

Regards
M.




reply via email to

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