unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: Stefan Israelsson Tampe <stefan.itampe@gmail.com>
To: Ian Price <ianprice90@googlemail.com>
Cc: 14347@debbugs.gnu.org, Jussi Piitulainen <jpiitula@ling.helsinki.fi>
Subject: bug#14347: reset, shift, continuation values truncated inconsistently
Date: Mon, 6 May 2013 23:15:13 +0200	[thread overview]
Message-ID: <CAGua6m0E_5CS_rAN+mdhzn=4eABdQcQb8AL2S3xRMTGhNkq0-g@mail.gmail.com> (raw)
In-Reply-To: <8761ywexmx.fsf@Kagami.home>

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

Hmm, we have

(let ((k (cal-with-prompt tag (-- expr that ends with (values a b c) --)
 (-- expr that is of unknown values length --))))
  (k))

So it looks like peval.scm in language/tree-il does not handle this well.

Looking in that file we have

(($ <prompt> src tag body handler)
       (define (make-prompt-tag? x)
         (match x
           (($ <application> _ ($ <primitive-ref> _ 'make-prompt-tag)
               (or () ((? constant-expression?))))
            #t)
           (_ #f)))

       (let ((tag  (for-value tag))
             (body (for-tail body)))

       ... cases where we can optimize sue to knowledge of prompt-tag ...

       (else
           (make-prompt src tag body (for-value handler))))))

So to me it looks like peval does a for-tail on body, and uses the value
constraint on the body. I'm not sure how to fix this though.

But that this is the problem can be shown by changing the code to

(($ <prompt> src tag body-in handler)
       (define (make-prompt-tag? x)
         (match x
           (($ <application> _ ($ <primitive-ref> _ 'make-prompt-tag)
               (or () ((? constant-expression?))))
            #t)
           (_ #f)))

       (let ((tag  (for-value tag))
             (body (for-tail body-in)))

       ... cases where we can optimize sue to knowledge of prompt-tag ...

       (else

   (make-prompt src tag (for-values body-in) (for-value handler))))))

/Stefan



On Mon, May 6, 2013 at 9:06 PM, Ian Price <ianprice90@googlemail.com> wrote:

> Jussi Piitulainen <jpiitula@ling.helsinki.fi> writes:
>
> > The documentation for reset and shift in the
> > manual does not quite say, but I believe the
> > captured continuation in these examples should be
> > the continuation of the shift expression inside
> > the reset expression, that is, it should simply
> > return the three values in all cases.
> Totally agree, this is the behaviour I expect
>
> > scheme@(guile-user)> (let ((k (reset (shift k k) (values 3.1 2 3))))
> (k))
> > $7 = 3.1
>
> scheme@(guile-user)> (import (only (rnrs) let-values))
> scheme@(guile-user)> (let ((k (reset (shift k k) (values 3.1 2 3)))) (k))
> $40 = 3.1
> scheme@(guile-user)> (let-values (((k) (reset (shift k k) (values 3.1 2
> 3)))) (k))
> $41 = 3.1
> $42 = 2
> $43 = 3
>
> So, my first suspicion was that there is some part of the code that
> receives the multiple values in a let or something, but neither the
> code, nor the ,expand command revealed that. However, when we check with
> ,optimize
>
> (let ((k (call-with-prompt
>            ((@@ (ice-9 control) default-prompt-tag))
>            (lambda ()
>              (apply abort
>                     ((@@ (ice-9 control) default-prompt-tag))
>                     (lambda (cont)
>                       (call-with-prompt
>                         ((@@ (ice-9 control) default-prompt-tag))
>                         (lambda ()
>                           (lambda vals
>                             (call-with-prompt
>                               ((@@ (ice-9 control) default-prompt-tag))
>                               (lambda () (@apply cont vals))
>                               (lambda (cont f) (f cont)))))
>                         (lambda (cont f) (f cont))))
>                     '())
>              3.1)
>            (lambda (cont f) (f cont)))))
>   (k))
>
> Gotcha. The optimizer is getting rid of the multiple values.
> On #guile, mark_weaver reminded me of
> http://debbugs.gnu.org/cgi/bugreport.cgi?bug=13966 which I think is the
> same issue. But I haven't tested that yet.
>
> --
> Ian Price -- shift-reset.com
>
> "Programming is like pinball. The reward for doing it well is
> the opportunity to do it again" - from "The Wizardy Compiled"
>
>
>
>

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

  reply	other threads:[~2013-05-06 21:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-04  7:47 bug#14347: reset, shift, continuation values truncated inconsistently Jussi Piitulainen
2013-05-06 19:06 ` Ian Price
2013-05-06 21:15   ` Stefan Israelsson Tampe [this message]
2016-06-20 21:06 ` Andy Wingo

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='CAGua6m0E_5CS_rAN+mdhzn=4eABdQcQb8AL2S3xRMTGhNkq0-g@mail.gmail.com' \
    --to=stefan.itampe@gmail.com \
    --cc=14347@debbugs.gnu.org \
    --cc=ianprice90@googlemail.com \
    --cc=jpiitula@ling.helsinki.fi \
    /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).