From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Israelsson Tampe Newsgroups: gmane.lisp.guile.bugs Subject: bug#14347: reset, shift, continuation values truncated inconsistently Date: Mon, 6 May 2013 23:15:13 +0200 Message-ID: References: <8761ywexmx.fsf@Kagami.home> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=047d7b675a5a54c5dd04dc133224 X-Trace: ger.gmane.org 1367874976 18331 80.91.229.3 (6 May 2013 21:16:16 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 6 May 2013 21:16:16 +0000 (UTC) Cc: 14347@debbugs.gnu.org, Jussi Piitulainen To: Ian Price Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Mon May 06 23:16:15 2013 Return-path: Envelope-to: guile-bugs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UZSla-0005WR-60 for guile-bugs@m.gmane.org; Mon, 06 May 2013 23:16:14 +0200 Original-Received: from localhost ([::1]:55244 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UZSlZ-0000Yj-OU for guile-bugs@m.gmane.org; Mon, 06 May 2013 17:16:13 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:53981) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UZSlT-0000XD-KP for bug-guile@gnu.org; Mon, 06 May 2013 17:16:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UZSlQ-0007Xq-2l for bug-guile@gnu.org; Mon, 06 May 2013 17:16:07 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:56149) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UZSlP-0007Xk-Ux for bug-guile@gnu.org; Mon, 06 May 2013 17:16:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1UZSmM-0002Ns-90 for bug-guile@gnu.org; Mon, 06 May 2013 17:17:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Israelsson Tampe Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-guile@gnu.org Resent-Date: Mon, 06 May 2013 21:17:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 14347 X-GNU-PR-Package: guile X-GNU-PR-Keywords: Original-Received: via spool by 14347-submit@debbugs.gnu.org id=B14347.13678749799050 (code B ref 14347); Mon, 06 May 2013 21:17:02 +0000 Original-Received: (at 14347) by debbugs.gnu.org; 6 May 2013 21:16:19 +0000 Original-Received: from localhost ([127.0.0.1]:60258 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UZSld-0002Lr-Ju for submit@debbugs.gnu.org; Mon, 06 May 2013 17:16:19 -0400 Original-Received: from mail-pd0-f169.google.com ([209.85.192.169]:56293) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UZSlZ-0002Le-Bj for 14347@debbugs.gnu.org; Mon, 06 May 2013 17:16:16 -0400 Original-Received: by mail-pd0-f169.google.com with SMTP id 14so2227955pdc.0 for <14347@debbugs.gnu.org>; Mon, 06 May 2013 14:15:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=urnOtolW1Xxag8d3Ejpds9VEKAOqtorZ5LDz50lKCHM=; b=jCIiiO6+KVoavcuATskfkvfnnTpdIyPH7LoRrd6I/2U1lO5c5ae59Y1vqlaFnp8VRZ 7ZEJhjiziTPgSmO1E1YS2/9EYO9otncLUSHPYeCbjOsos6FdNskB1u+FU30oS52Fh2aK QAzqebs4KboXXjy9WwqfNLj7Bn0fPTpJrNZC8+05BHJoXJrrCSPxY4MA28Ym2VtoLTIp g0Uoy3im6UDkZ5Ddujoo8P4rbDc08iYizbmTA4lMXJvelV6drLl8rmj8TS93fuGeNYBz AdvniRyIjGsAsPSuiNw7+d+BMqSeLRILUgEwZLPRSKJBjCPAJ3H6srUfZZ/wyppq9Hfp KKOw== X-Received: by 10.68.90.197 with SMTP id by5mr27636526pbb.196.1367874913746; Mon, 06 May 2013 14:15:13 -0700 (PDT) Original-Received: by 10.70.22.5 with HTTP; Mon, 6 May 2013 14:15:13 -0700 (PDT) In-Reply-To: <8761ywexmx.fsf@Kagami.home> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 140.186.70.43 X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Original-Sender: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.bugs:7120 Archived-At: --047d7b675a5a54c5dd04dc133224 Content-Type: text/plain; charset=ISO-8859-1 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 (($ src tag body handler) (define (make-prompt-tag? x) (match x (($ _ ($ _ '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 (($ src tag body-in handler) (define (make-prompt-tag? x) (match x (($ _ ($ _ '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 wrote: > Jussi Piitulainen 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" > > > > --047d7b675a5a54c5dd04dc133224 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Hmm, we have

(let ((k (cal-with-p= rompt 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 t= his well.

Looking in that file we have=

(($ <prompt> src tag body = handler)
       (define (make-prompt-tag? x)
&nbs= p;        (match x
       = ;    (($ <application> _ ($ <primitive-ref> _ 'ma= ke-prompt-tag)
              &= nbsp;(or () ((? constant-expression?))))
            #t)
    =        (_ #f)))

    =    (let ((tag  (for-value tag))
    &nbs= p;        (body (for-tail body)))
  &nbs= p;
       ... cases where we can optimi= ze sue to knowledge of prompt-tag ...

       (else
  =          (make-prompt src tag body (for-value hand= ler))))))

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 b= y changing the code to

(($ <pr= ompt> src tag body-in handler)
       (def= ine (make-prompt-tag? x)
         (match x
    &nb= sp;      (($ <application> _ ($ <primitive-ref> = _ 'make-prompt-tag)
           =    (or () ((? constant-expression?))))
    &= nbsp;       #t)
         =  (_ #f)))

       (let ((tag  (for-value = tag))
             (body (for-= tail body-in)))
   
      &nbs= p;... cases where we can optimize sue to knowledge of prompt-tag ...
<= div>
       (else

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

/Stefan

<= /div>


On Mon, May 6, 2013 at 9:06 PM, Ian Pric= e <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 =3D 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 =3D 3.1
scheme@(guile−user)> (let-values (((k) (reset (shift k k) (values = 3.1 2 3)))) (k))
$41 =3D 3.1
$42 =3D 2
$43 =3D 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-promp= t-tag))
           (lambda ()
             (apply abort
                    ((@@ = (ice-9 control) default-prompt-tag))
                    (lamb= da (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=3D13966 which I th= ink is the
same issue. But I haven't tested that yet.

--
Ian Price -- shift-res= et.com

"Programming is like pinball. The reward for doing it well is
the opportunity to do it again" - from "The Wizardy Compiled"= ;




--047d7b675a5a54c5dd04dc133224--