Hi all,

I'm trying to embed racket 3m version as interpreter into GUI application. For 
custom interpreters this application have two required APIs - first one is init 
and the second one is eval string. So in init I'm calling 
scheme_register_tls_space and scheme_main_setup after. And in eval I'm using 
custom version of Racket's read-eval-print-loop without recursion for 
evaluation of thrings. And everything is working well until I've tried to 
implement generator. Some reading of sources lead we into problem of 
continuation. This simple code leads to error "continuation application: 
attempt to cross a continuation barrier". 

(define (generate-one-element-at-a-time lst)
 
  (define (control-state return)
    (for-each 
     (lambda (element)
               (set! return (call-with-current-continuation
                              (lambda (resume-here)
                                ;; Grab the current continuation
                               (set! control-state resume-here)
                               (return element)))))
     lst)
    (return 'you-fell-off-the-end))
 
  (define (generator)
    (call-with-current-continuation control-state)) 
 
  ;; Return the generator 
  generator)
 
(define generate-digit
  (generate-one-element-at-a-time '(0 1 2)))
 
(generate-digit) ;; 0
(generate-digit) ;; 1 ;; error "continuation application: attempt to cross a 
continuation barrier"

Attemt to use generators library lead to memory access violation. I suppose the 
problem lies in stack frames which are cleared every time eval callback from 
the main program is called. For some reasons I can't run racket in another 
thread. So may be there is an option how this problem could be solved? May be 
my assumption is not right? May be switch to CGC and mapping stack with 
scheme_set_stack_base into heap can help? If it help I can show the source of 
this plugin.

Thanks, 
Kirill
____________________
  Racket Users list:
  http://lists.racket-lang.org/users

Reply via email to