[racket] Engineering Tradeoffs of ANF transforms and the Stateless Server

From: Galler (lzgaller at optonline.net)
Date: Fri Dec 30 14:37:10 EST 2011

FYI, C-level implementation appears to be in src\fun.c, line 7722 as 
*scheme_dynamic_wind



Jay,

->dynamic-wind issue
--------------------------

The short answer is the code I'm working on is an implementation of 
Harel's hierarchical state machine formalism.

I hesitate to provide a long answer as I fear it would be an imposition 
on your time and goodwill. Though I'm happy to provide, if you ask.

After some rewriting, the narrow issue in getting the stateless language 
to work for this application is a rewrite of the higher-order primitive 
dynamic-wind.

This is the known issue with needing to rewrite higher order functions. 
Not a surprise.

Below is the relevant code snippet, but,again,  it could be any 
arbitrary higher order function

I've grepped the racket/src directory without success

and read  'The Scheme of Things: The June 1992 Meeting- Appendix A" by 
Rees and "Contstraining Control" by Friedman and Hayes

but both appear to require redefining call/cc which seems like it might 
be problematic unless done in a compatible way with racket and #lang 
web-server .

Can you provide any guidance on a re-implementation of dynamic-wind?

Thanks again for the assistance.


#|
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Capturing a stateless continuation within context of dynamic wind raises 
exception
" Attempt to capture a continuation from within an unsafe context:"

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|#


#lang web-server

(require web-server/servlet-env)

(define (main-entry request)
   (dynamic-wind
    void
    (λ () (send/suspend
     (lambda (k-url)
       (response/xexpr
        `(html (body (a ([href ,k-url]) "Hello world!")))))))
    void))


(define (start request)
   (printf "calling start\n")
      (main-entry request))


(serve/servlet start
                  #:stateless? #t
                  #:launch-browser? #t)

#|
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
END CODE
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|#



Posted on the users mailing list.