unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Stefan Israelsson Tampe <stefan.itampe@gmail.com>
To: Mark H Weaver <mhw@netris.org>
Cc: guile-devel <guile-devel@gnu.org>
Subject: Re: Special variables to relax boxing
Date: Thu, 21 Mar 2013 21:15:44 +0100	[thread overview]
Message-ID: <12515493.61rmnodEK6@warperdoze> (raw)
In-Reply-To: <87d2usa845.fsf@tines.lan>

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




  reply	other threads:[~2013-03-21 20:15 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-19 22:05 Special variables to relax boxing Stefan Israelsson Tampe
2013-03-21  6:00 ` Mark H Weaver
2013-03-21  9:35   ` Stefan Israelsson Tampe
2013-03-21 15:35     ` Noah Lavine
2013-03-21 16:28       ` Stefan Israelsson Tampe
2013-03-21 19:03     ` Mark H Weaver
2013-03-21 20:15       ` Stefan Israelsson Tampe [this message]
2013-03-21 21:11         ` Noah Lavine
2013-03-22 22:33           ` Stefan Israelsson Tampe
2013-03-23  0:18             ` Daniel Hartwig
2013-03-23 15:34       ` Stefan Israelsson Tampe
2013-03-23 18:31         ` Stefan Israelsson Tampe
  -- strict thread matches above, loose matches on Subject: below --
2013-03-23 10:30 Stefan Israelsson Tampe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=12515493.61rmnodEK6@warperdoze \
    --to=stefan.itampe@gmail.com \
    --cc=guile-devel@gnu.org \
    --cc=mhw@netris.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).