From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) Newsgroups: gmane.lisp.guile.bugs Subject: bug#13966: inlining issue? Date: Fri, 22 Mar 2013 14:55:35 +0100 Message-ID: <87sj3nfsiw.fsf@gnu.org> References: <41C98E11-DE0A-432E-9947-7F75B572FB12@bluewin.ch> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1363960574 26784 80.91.229.3 (22 Mar 2013 13:56:14 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 22 Mar 2013 13:56:14 +0000 (UTC) Cc: 13966@debbugs.gnu.org To: Daniel Llorens Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Fri Mar 22 14:56:36 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 1UJ2SS-0002e5-2Q for guile-bugs@m.gmane.org; Fri, 22 Mar 2013 14:56:36 +0100 Original-Received: from localhost ([::1]:33612 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UJ2S4-0001Ji-Ef for guile-bugs@m.gmane.org; Fri, 22 Mar 2013 09:56:12 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:55769) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UJ2S0-0001JQ-9A for bug-guile@gnu.org; Fri, 22 Mar 2013 09:56:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UJ2Ry-00063M-HK for bug-guile@gnu.org; Fri, 22 Mar 2013 09:56:08 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:36864) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UJ2Ry-00063I-Cz for bug-guile@gnu.org; Fri, 22 Mar 2013 09:56:06 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1UJ2Tq-00010C-CV for bug-guile@gnu.org; Fri, 22 Mar 2013 09:58:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-guile@gnu.org Resent-Date: Fri, 22 Mar 2013 13:58:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 13966 X-GNU-PR-Package: guile X-GNU-PR-Keywords: Original-Received: via spool by 13966-submit@debbugs.gnu.org id=B13966.13639606573818 (code B ref 13966); Fri, 22 Mar 2013 13:58:02 +0000 Original-Received: (at 13966) by debbugs.gnu.org; 22 Mar 2013 13:57:37 +0000 Original-Received: from localhost ([127.0.0.1]:40973 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UJ2TR-0000zW-7v for submit@debbugs.gnu.org; Fri, 22 Mar 2013 09:57:37 -0400 Original-Received: from xanadu.aquilenet.fr ([88.191.123.111]:58394) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UJ2TN-0000zM-Md for 13966@debbugs.gnu.org; Fri, 22 Mar 2013 09:57:35 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by xanadu.aquilenet.fr (Postfix) with ESMTP id 9CD66C040; Fri, 22 Mar 2013 14:55:35 +0100 (CET) Original-Received: from xanadu.aquilenet.fr ([127.0.0.1]) by localhost (xanadu.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id cfIOzDCyW+kd; Fri, 22 Mar 2013 14:55:35 +0100 (CET) Original-Received: from pluto (nat-eduroam-36-gw-01-bso.bordeaux.inria.fr [194.199.1.36]) by xanadu.aquilenet.fr (Postfix) with ESMTPSA id 489C815C8; Fri, 22 Mar 2013 14:55:35 +0100 (CET) In-Reply-To: <41C98E11-DE0A-432E-9947-7F75B572FB12@bluewin.ch> (Daniel Llorens's message of "Fri, 15 Mar 2013 13:57:26 +0100") User-Agent: Gnus/5.130005 (Ma Gnus v0.5) Emacs/24.2 (gnu/linux) 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:6990 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi Daniel, Daniel Llorens skribis: > Compare=20 > > (define f (lambda (a) a)) > (call-with-values (lambda () (values 3 3)) f) > > vs > > (call-with-values (lambda () (values 3 3)) (lambda (a) a)) > > The first one fails with > > :1:0: In procedure f: > :1:0: Wrong number of arguments to # > > The second one gives 3.=20 > > This is Guile 2.0.7.112-f5ea5. > > The behavior of the first case makes (compose f g) fail when f takes less= args tan g produces. That is unfortunate but I think the former is correct. R5RS doesn=E2=80=99t say anything about the expected behavior when the prod= ucer returns a number of values incompatible with what the consumer accepts. R6RS says (Section 5.8): If the number of return values passed to a continuation created by a call to call-with-values is not accepted by its consumer that was passed in that call, then an exception is raised. and Section 11.5: Consumer must be a procedure and should accept as many values as producer returns. R7RS draft #6 uses equivalent wording (I think): Calls its producer argument with no values and a continuation that, when passed some values, calls the consumer procedure with those values as arguments. This patch fixes peval to not inline (call-with-values (lambda () (values vals ...)) (lambda (args ...) ...)) when the length of =E2=80=98vals=E2=80=99 differs from that of =E2=80=98arg= s=E2=80=99. However, it=E2=80=99s not very elegant, IMO. Andy? Ludo=E2=80=99. --=-=-= Content-Type: text/x-patch Content-Disposition: inline diff --git a/module/language/tree-il/peval.scm b/module/language/tree-il/peval.scm index bf96179..25dded4 100644 --- a/module/language/tree-il/peval.scm +++ b/module/language/tree-il/peval.scm @@ -1155,6 +1155,25 @@ top-level bindings from ENV and return the resulting expression." (simplify-conditional (make-conditional src c (for-tail subsequent) (for-tail alternate)))))) + + (($ src + ($ _ '@call-with-values) + (($ _ _ + ($ _ + () #f #f #f () () + ($ _ ($ _ 'values) + (produced ...)) + #f)) + ($ _ _ + (and consumer + ($ _ + (? (negate (compose (cute = <> (length produced)) + length))) + #f #f #f () gensyms body #f))))) + ;; Producer is (values args ...) but consumer expects a different + ;; number of values, which is an error. + exp) + (($ src ($ _ '@call-with-values) (producer --=-=-=--