unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Noah Lavine <noah.b.lavine@gmail.com>
To: Stefan Israelsson Tampe <stefan.itampe@gmail.com>
Cc: guile-devel <guile-devel@gnu.org>
Subject: Re: redo-safe-variables and redo-safe-parameters
Date: Wed, 27 Mar 2013 17:44:32 -0400	[thread overview]
Message-ID: <CA+U71=NJaAWQ73TrUSG2AVPHeuvZo5fxHJTgK8wP75DrRX_HUw@mail.gmail.com> (raw)
In-Reply-To: <36877746.VlrjcRTRXD@warperdoze>

[-- Attachment #1: Type: text/plain, Size: 2234 bytes --]

Hello,

On Wed, Mar 27, 2013 at 12:15 PM, Stefan Israelsson Tampe <
stefan.itampe@gmail.com> wrote:

> Hmm, your really are right in the sense that the common ideom in
> computer language design is to type a variable at the declaration of
> the variable. So basically a user would then do something like
> (for ((~ i) from 0) code ...) to force the intruduction of a redo safe
> variable. Hmm yolly good. This might be the better semantic and not
> trust so much on some magic. I would still require (set~ i 1) and (~
> i) for these variables? With this approach you might want to consider
> to change with-redo-varibles e.g.
>
> (with-redo-variables (((~ a) 1)) code ...)
>
> to guard it in a redo safe manner and then
>
> (with-redo-variables ((a 1)) code ...)
>
> as a normal variable and beeing a noop. Error checking can be done via
> macros so now everything can be made ontop on a rich syntax system and
> r5rs.
>
> Does this sounds like as a better approach?
>

It may be a better approach. If so, you can implement this with Guile's
current support for fluids (or parameters, probably, if you wanted to).
Define (~ i) to be (fluid-ref i) and (set~ i x) to be (fluid-set! i x).

You can even implement with-redo-variables this way, using something like

(define-syntax with-redo-variables
  (syntax-rules (~)
    ((_ (((~ var) val) . rest) code ...)
     (let ((var (make-fluid)))
      (with-fluids ((var val))
        (with-redo-variables rest code ...))))
    ((_ ((var val) . rest) code ...)
     (let ((var val))
      (with-redo-variables rest code ...)))
    ((_ () code ...)
     (begin code ...))))

And using the definitions of ~ and set~ above. I haven't tested that, so it
probably doesn't work. I imagine that you could make it work with
parameters pretty easily too.

Since it's definable with such a simple macro, I don't think it's
appropriate for a SRFI.

To me, the more interesting point you've raised is the idea that Elisp
variables should map to fluids rather than regular Scheme variables. That
may be important of Elisp ever starts interacting with continuations. But
that will require some more thought. I don't think it matters much now (if
it did, presumably guile-emacs would have problems).

Noah

[-- Attachment #2: Type: text/html, Size: 2922 bytes --]

  reply	other threads:[~2013-03-27 21:44 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-26 17:40 redo-safe-variables and redo-safe-parameters Stefan Israelsson Tampe
2013-03-26 18:05 ` Noah Lavine
2013-03-26 20:43   ` Stefan Israelsson Tampe
2013-03-26 21:07     ` Noah Lavine
     [not found]       ` <CAGua6m0WyG2_Bk3+b8UDn6ee=mddmmaOPQiF9sJf+jYtE3LsgQ@mail.gmail.com>
2013-03-26 21:38         ` Noah Lavine
2013-03-26 22:01           ` Stefan Israelsson Tampe
2013-03-26 22:36             ` Noah Lavine
2013-03-27  7:13               ` Stefan Israelsson Tampe
2013-03-27 12:42                 ` Noah Lavine
2013-03-27 13:22                   ` Stefan Israelsson Tampe
2013-03-27 14:29                     ` Noah Lavine
2013-03-27 15:04                       ` Stefan Israelsson Tampe
2013-03-27 15:29                         ` Noah Lavine
2013-03-27 16:15                           ` Stefan Israelsson Tampe
2013-03-27 21:44                             ` Noah Lavine [this message]
2013-03-27 21:46                               ` Noah Lavine
2013-03-28  8:36                                 ` Stefan Israelsson Tampe
2013-03-27 21:37                       ` Stefan Israelsson Tampe
2013-03-28 18:03   ` Stefan Israelsson Tampe
2013-03-31 21:16     ` Stefan Israelsson Tampe
2013-04-01  1:23       ` Noah Lavine
2013-04-01  1:37       ` Daniel Hartwig
  -- strict thread matches above, loose matches on Subject: below --
2013-04-01 10:17 Stefan Israelsson Tampe
2013-04-03 19:36 Stefan Israelsson Tampe
2013-04-13 10:12 ` Stefan Israelsson Tampe
2013-04-04 21:13 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='CA+U71=NJaAWQ73TrUSG2AVPHeuvZo5fxHJTgK8wP75DrRX_HUw@mail.gmail.com' \
    --to=noah.b.lavine@gmail.com \
    --cc=guile-devel@gnu.org \
    --cc=stefan.itampe@gmail.com \
    /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).