On Thursday, March 21, 2013 03:03:06 PM Mark H Weaver wrote: > Stefan, you're still describing your proposal in terms of low-level > implementation details such as stacks. In the general case, we cannot > store environment structures on the stack. Furthermore, in the > general case *all* variables in scheme are bound to locations, not > values. Only in special cases can we use stacks, and only in special > cases can we avoid boxing variables. These are only _optimizations_. > > If you're serious about this proposal, please read sections 3.1 and > 3.4 of the R5RS carefully. Explain your proposed _semantics_ (not > the implementation details) in those terms, where *all* variables are > bound to _locations_, and where there is no stack at all (everything > is conceptually stored in a garbage-collected heap). > > We need to understand the *semantics* in the simplest possible terms > before we even begin to think about how to implement it. > > Thanks, > Mark
Ok, the sematics for the simple version is are, Assume k, the continuation associated with with a dynamic wind or unwind assume that there is a map from each continuation (k,id) to a value and getting and setting of this value is done through ref-get and ref-set, assume that the winder and the rewinder lambda takes a first argument k beeing the continuation under action, finally make-id will make a unique object. then the semantic would be: (define-syntax-rule (with-special (a) code) (let ((id (make-id))) (dynamic-wind (lambda (k) (set! a (ref-get k id))) (lambda () code) (lambda (k) (ref-set! k id a))))) A possible refinment of this is associate to k two predicates e.g. (do-wind? k kind) predicate and a (do-unwind? k kind) wich takes a parameter kind, then use the semanics (define-syntax-rule (with-special (a kind) code) (let ((id (make-id))) (dynamic-wind (lambda (k) (when (do-wind? k kind) (set! a (ref-get k id)))) (lambda () code) (lambda (k) (when (do-unwind? k kind) (ref-set! k id a)))))) Hopes this helps! /Stefan