Hi Laurent,

> (class +Content +Entity)
> (rel data (+Number))
> (rel containers (+List +Joint) contents (+Container))
> (class +Container +Entity)
> (rel data (+Number))
> (rel contents (+List +Joint) containers (+Content))
> (pool "/tmp/test.db")
> (setq objContainer
>    (obj
>       ((+Container))
>       data 52 ) )
> (commit)
> (setq objContent
>    (obj
>       ((+Content))
>       data 25 ) )
> (commit)

This is good!

> (put!>
>    objContent
>    'containers
>    (append (; 'objContent containers) objContainer) )

Note that (; 'objContent containers) is not correct, because the quoted
symbol 'objContent' doesn't evaluate to an entity.

Better would be (; objContent containers). But this wasn't a problem
here, because both expressions still give NIL.

> (show objContent)
> (show objContainer)


> (zap objContainer)

This is the problem! 'zap' should generally not be called in application
code, because it does a hard-core removal of the object, without taking
care of relations.

Use (lose!> objContainer) to clean up all relations as needed, and mark
the object for final deletion. This will happen at the next call of

   (load "@lib/too.l")

'dbgc' is usually called by a process started from a nightly cron job,
and internally calls 'zap' if the object is not referenced from other

: (show objContent)
{3} (+Content)          # The joint is gone
   data 25

: (show objContainer)
   T                    # Object is marked for deletion
   contents ({3})
   data 52
-> {2}

   (Note that the back-link 'contents ({3})' still exists in the "lost"
   object. So you still can undo the 'lose>' here with

      (keep!> objContainer)

   and the full joint would be re-established)

: (dbgc)  # Call garbage collector
-> 2

:  (show objContainer)
!? (val "X")
{2} -- Bad ID           # Object is gone
{2} ?

> Please consider that I'm very new to picolisp (and to lisp more
> generally) so I may make basic mistakes.

No problem! :)

- Alex
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

Reply via email to