Hello - I wanted to see if I understand garbage collection correctly in
regards to CLOS objects. Let's say the method foo takes a Line object, and
the method bar takes two Point objects, and I want to use bar in foo. In
the following code, will the two Point instances be removed by the garbage
collection because they aren't bound to a symbol?
(defmethod first-func ((line Line))
(second-func
(make-instance 'Point
:coords (x (first-vertex line))
(y (first-vertex line)))
(make-instance 'Point
:coords (x (last-vertex line))
(y (last-vertex line)))))
(defmethod second-func ((point1 Point) (point2 Point))
; etc., etc.)
Disclaimer: This is not a class assignment. I am a non-CS grad student
learning CL for my dissertation work.
Cheers...........
Kevin
--------------------------------Bermuda Massive
Kevin Mayall ·······@uwaterloo.ca
http://www.fes.uwaterloo.ca/u/kmayall/
School of Planning, University of Waterloo
--
--------------------------------Bermuda Massive
Kevin Mayall ·······@uwaterloo.ca
http://www.fes.uwaterloo.ca/u/kmayall/
School of Planning, University of Waterloo
·······@cousteau.uwaterloo.ca wrote about
"Garbage collection and CLOS":
> Hello - I wanted to see if I understand garbage collection correctly in
> regards to CLOS objects. Let's say the method foo takes a Line object,
> and the method bar takes two Point objects, and I want to use bar in
> foo. In the following code, will the two Point instances be removed by
> the garbage collection because they aren't bound to a symbol?
>
> (defmethod first-func ((line Line))
> (second-func
> (make-instance 'Point
> :coords (x (first-vertex line))
> (y (first-vertex line)))
> (make-instance 'Point
> :coords (x (last-vertex line))
> (y (last-vertex line)))))
>
> (defmethod second-func ((point1 Point) (point2 Point))
> ; etc., etc.)
>
>
> Disclaimer: This is not a class assignment. I am a non-CS grad student
> learning CL for my dissertation work.
>
But in 'second-func' the Point objects will be bound to symbols, namely
point1 and point2 ;-).
For an object to be excepted from gc, it is not necessary that it is
bound to a symbol. It just has to be 'accessible', i.e. it must be
possible to access it from some language construct.
E.G.
(setq x (list (make-instance 'Point ...
Here a Point-object is 'nameless', but it is accessible.
Dieter