Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C to JavaScript

Name: Anonymous 2011-03-16 17:09

I know a good few hardcore C peeps lurk around here, is this possible?

 (*p)++

Name: Anonymous 2011-03-16 19:46

>>8
Well, I assumed it was just a pointer for setjmp/longjmp.
So I think you can emulate it with a simple try/catch in JS.
Yes, probably, though presumably this would make setjmp/longjmp have to be special forms and not be available as library functions?
This thing is nowhere close to call-cc.
And how, so few guarantees.

For the record, a js translation of
(define (setjmp! env)
  (call/1cc (lambda (k)
             (env-set! env k)
             0)))
(define (longjmp! env val)
  ((env-get env)
   (if (zero? val)
       1
       val)))

should work, with the proviso that if the setjmping function returns it doesn't invalidate the stack context.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List