Is the garbage collection in picolisp immediate if the resource can be
No, picolisp uses a mark and sweep halt the world garage collector. During
sweep phase the complete allocated RAM is checked. If that would happen
after each release of a resource picolisp would be very slow.
Furthermore in Picolisp it is not possible to decide whether a resource can
be released or not with out doing mark and sweep. This is because of cyclic
list and the fact that you could always have a symbol pointing to that cell.
2017-03-03 12:04 GMT+01:00 Lindsay John Lawrence <
> Is the garbage collection in picolisp immediate if the resource can be
> The initial iterative replacement solution I came up with (below) quickly
> runs out of resources as it has to build the entire list before starting to
> I haven't figured out how to do it yet, but I think, in this case, a
> 'recursive' solution that renders as points are created would use a lot
> less resources, assuming that processed replacement rules are garbage
> collected as the stack unwinds and elements are traversed over.
> It would be a nice accomplishment to be able to render the more complex
> fractal plants expressed here: https://en.wikipedia.org/wiki/L-system
> # https://en.wikipedia.org/wiki/Gosper_curve
> # Angle 60 degrees = PI/3
> # Axiom A
> # Replacement Rules
> # A :--> A - B - - B + A + + A A + B -
> # B :--> + A - B B - - B - A + + A + B
> # C (initially = A) grows...very quickly.
> #: n=0 (length C) -> 15
> #: n=1 (length (setq C (F C))) -> 113
> #: n=2 -> 799, n=3 -> 5601, n=4 -> 39215, n=5 -> 274513, n=6 -> 1921599,
> n=7 .
> # For n=6...
> : (bench (nil (Draw-Gosper-Curve)))
> -> 1.370 sec
> Which works out to:
> XY Cnt: 823543 coordinates to plot
> Min-XY: -66,432.00 -42,345.11
> Max-XY: 2,048.00 23,611.35"
> ...about 900K of serialized canvas instructions.
> Full-code at: https://github.com/thinknlive/picolisp-gosper
> (de Gosper-Curve (Length Angle N)
> (A (chop "A-B--B+A++AA+B-")
> B (chop "+A-BB--B-A++A+B")
> C A
> F '((L) (fish atom
> (mapcar '((X)
> ((= X "A") A)
> ((= X "B") B)
> (T X))) L))) )
> # Generate points
> (do N (setq C (F C)))
> # Plot points
> (map '((R)
> (case (car R)
> (("A" "B") (Plot-Line Length Angle))
> ("+" (setq Angle (+ Angle PI/3)))
> ("-" (setq Angle (- Angle PI/3)))
> (T (msg (text "?Gosper-Curve: No-match: @1" @))) )) C )
> ) )