Welcome to the CHICKEN Scheme pasting service

C-Keen C-Keen C-Keen added by zbigniew the recursed on Sun Mar 4 22:20:47 2012

jim@aeryn ~/scheme/tmp$ cat callback.scm

(use srfi-18)

(define foo (foreign-safe-lambda* void () #<<EOF
SL("foo");
EOF
))

(define foo10 (foreign-safe-lambda* void () #<<EOF
SL10("foo10");
EOF
))

;; ok
;; (define-external (SL   (c-string x)) int (print x " " (string-length x)) (thread-sleep! 2) (print x " done"))
;; (define-external (SL10 (c-string x)) int (print x " " (string-length x)) (thread-sleep! 1) (print x " done"))

;; crash
(define-external (SL   (c-string x)) int (print x " " (string-length x)) (thread-sleep! 1) (print x " done"))
(define-external (SL10 (c-string x)) int (print x " " (string-length x)) (thread-sleep! 2) (print x " done"))


(thread-start! foo10)
(foo)

jim@aeryn ~/scheme/tmp$ csc callback.scm
clang: warning: argument unused during compilation: '-no-cpp-precomp'

jim@aeryn ~/scheme/tmp$ ./callback
foo 3
foo10 5
foo done
foo done
[panic] callback returned twice - execution terminated

callback.scm:22: thread-start!
callback.scm:23: foo
##sys#gc
g45
##sys#peek-c-string
callback.scm:18: print
callback.scm:18: thread-sleep!
##sys#gc
g1112
##sys#peek-c-string
callback.scm:19: print
callback.scm:19: thread-sleep!
callback.scm:18: print
callback.scm:18: print  <--

Your annotation:

Enter a new annotation:

Your nick:
The title of your paste:
Your paste (mandatory) :
What's the R5RS procedure to access the first element of a pair?
Visually impaired? Let me spell it for you (wav file) download WAV