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.devel Subject: Re: [PATCH 6/9] Add arity-adapting module Date: Thu, 29 Aug 2013 23:08:11 +0200 Message-ID: <87vc2o5hok.fsf@gnu.org> References: <1377762579-9738-1-git-send-email-wingo@pobox.com> <1377762579-9738-7-git-send-email-wingo@pobox.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1377810521 28760 80.91.229.3 (29 Aug 2013 21:08:41 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 29 Aug 2013 21:08:41 +0000 (UTC) To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Thu Aug 29 23:08:41 2013 Return-path: Envelope-to: guile-devel@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 1VF9SJ-0001sh-Kh for guile-devel@m.gmane.org; Thu, 29 Aug 2013 23:08:39 +0200 Original-Received: from localhost ([::1]:45783 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VF9SJ-0002A9-5W for guile-devel@m.gmane.org; Thu, 29 Aug 2013 17:08:39 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41783) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VF9S9-000295-L8 for guile-devel@gnu.org; Thu, 29 Aug 2013 17:08:35 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VF9S3-00017n-VN for guile-devel@gnu.org; Thu, 29 Aug 2013 17:08:29 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:60392) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VF9S3-00016D-OI for guile-devel@gnu.org; Thu, 29 Aug 2013 17:08:23 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1VF9S2-0001j2-8H for guile-devel@gnu.org; Thu, 29 Aug 2013 23:08:22 +0200 Original-Received: from reverse-83.fdn.fr ([80.67.176.83]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 29 Aug 2013 23:08:22 +0200 Original-Received: from ludo by reverse-83.fdn.fr with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 29 Aug 2013 23:08:22 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 62 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: reverse-83.fdn.fr X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 12 Fructidor an 221 de la =?utf-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0xEA52ECF4 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 83C4 F8E5 10A3 3B4C 5BEA D15D 77DD 95E2 EA52 ECF4 X-OS: x86_64-unknown-linux-gnu User-Agent: Gnus/5.130007 (Ma Gnus v0.7) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:CofnFF3Nb16v/9H5YkfaUfFgUFU= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:16595 Archived-At: Andy Wingo skribis: > +;;; Commentary: > +;;; > +;;; A pass to adapt expressions to the arities of their continuations, > +;;; and to rewrite some tail expressions as primcalls to "return". > +;;; > +;;; Code: [...] > + (define (adapt-exp nvals k exp) > + (match nvals > + (0 > + (rewrite-cps-term (lookup-cont k conts) > + (($ $ktail) > + ,(let-gensyms (kvoid kunspec unspec) > + (build-cps-term > + ($letk* ((kunspec #f ($kargs (unspec) (unspec) > + ($continue k > + ($primcall 'return (unspec))))) > + (kvoid #f ($kargs () () > + ($continue kunspec ($void))))) > + ($continue kvoid ,exp))))) [...] > + (let ((drop-result > + (lambda (kseq) > + (let-gensyms (k* drop) > + (build-cps-term > + ($letk ((k* #f ($kargs ('drop) (drop) > + ($continue kseq ($values ()))))) > + ($continue k* ,exp))))))) Are ($void) and ($values ()) both equivalent to *unspecified*? > + (rewrite-cps-term (lookup-cont k conts) > + (($ $ktail) > + ,(rewrite-cps-term exp > + (($var sym) > + ($continue ktail ($primcall 'return (sym)))) > + (_ > + ,(let-gensyms (k* v) > + (build-cps-term > + ($letk ((k* #f ($kargs (v) (v) > + ($continue k > + ($primcall 'return (v)))))) > + ($continue k* ,exp))))))) > + (($ $ktrunc ($ $arity () () #f () #f) kseq) > + ,(drop-result kseq)) > + (($ $kargs () () _) > + ,(drop-result k)) > + (_ > + ($continue k ,exp))))))) Perhaps that happens in the Tree-IL->CPS pass, but is there/could there be an effect analysis when truncating multiple-value returns? Such that (f (values 1 2 3)) reduces to (f 1). Ludo’.