[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-guile-ncurses] effects in gc handlers
From: |
John Darrington |
Subject: |
Re: [Bug-guile-ncurses] effects in gc handlers |
Date: |
Mon, 2 May 2016 14:31:06 +0200 |
User-agent: |
Mutt/1.5.23 (2014-03-12) |
On Mon, May 02, 2016 at 03:08:44AM +0000, Mike Gran wrote:
On Saturday, April 30, 2016 5:30 PM, "address@hidden" <address@hidden>
wrote:
>Hello!
>
>Somebody was having trouble with gc semantics in ncurses. They were
>asking about how to ensure X would not be garbage collected before Y. I
>believe that should never be an issue when writing scheme code.
>So effects are being triggered by garbage collection. I suppose that
>this is done to try to make the library easier to use but in fact it
>cause an abstraction leak where programmers had to worry about GC
>semantics.
Thanks for looking at this. I'll consider it.
For the record, the user to whom rain1 is refering is me.
For background information, I was writing a small program like
(define stdscr (initscr))
;; Generate a window with a box around it and put another window inside it.
(let* ((h 4) (w 20) (sy 10) (sx 10)
(win (newwin h w sy sx))
(inner (derwin win (- h 2) (- w 4) 1 2))
(panel-desc (new-panel win))
(panel-desc2 (new-panel inner)))
(box win (acs-vline) (acs-hline))
(addstr inner "Hello world")
(update-panels)
(doupdate)
(getch inner)
(del-panel panel-desc)
(del-panel panel-desc2)
(endwin))
This works fine, so I thought I could make a procedure to do it multiple times.
(define stdscr (initscr))
;; Generate a window with a box around it and return the inner box
(define (new-boxed-win h w sy sx)
(let* ((win (newwin h w sy sx))
(inner (derwin win (- h 2) (- w 4) 1 2))
(panel-desc (new-panel win))
(panel-desc2 (new-panel inner)))
(box win (acs-vline) (acs-hline))
;; If the GC runs here, it will reap win, panel-desc and panal-desc2
inner))
(let* ((w1 (new-boxed-win 3 20 10 10))
(w2 (new-boxed-win 3 20 40 45)))
(addstr w1 "Hello")
(addstr w2 "Goodbye")
(update-panels)
(doupdate)
(getch w1)
(endwin))
Depending on when/if the garbage collector runs, this sometimes works, but
sometimes displays nothing, because all panels, and outer windows have get
garbage collected before they should be.
J'
--
Avoid eavesdropping. Send strong encryted email.
PGP Public key ID: 1024D/2DE827B3
fingerprint = 8797 A26D 0854 2EAB 0285 A290 8A67 719C 2DE8 27B3
See http://sks-keyservers.net or any PGP keyserver for public key.
signature.asc
Description: Digital signature