summaryrefslogtreecommitdiffstats
path: root/tests/012/fini.tl
blob: 3aa581f904766042027df87457147375086e6ff5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
(load "../common")

(defstruct base nil
  others
  id
  (:static counter 0)
  (:postinit (me) (set me.id (inc me.counter)))
  (:fini (me)
    (put-line `@(typeof me):@{me.id} finalized`)
    [mapdo call-finalizers me.others]))

(defstruct derived base
  (:fini (me)
    (put-line `@(typeof me):@{me.id} derived fini`)))

(unwind-protect
  (with-objects ((b (new base others (mapcar (ret (new derived)) (range 1 20)))))
    (put-line "inside with-objects"))
  (put-line "after with-objects"))

(mapcar (ret (new derived)) (range 1 20))
(sys:gc)