From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Mark H Weaver Newsgroups: gmane.lisp.guile.devel Subject: Re: Eval, tail calls, (current-module), and backward compatibility Date: Wed, 18 Jan 2012 14:58:49 -0500 Message-ID: <87zkdkye86.fsf@netris.org> References: <87lip70zz7.fsf@netris.org> <878vl6twvm.fsf@fencepost.gnu.org> <87ty3uyrdk.fsf@netris.org> <87sjjdfj3c.fsf@pobox.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1326916798 12334 80.91.229.12 (18 Jan 2012 19:59:58 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 18 Jan 2012 19:59:58 +0000 (UTC) Cc: guile-devel@gnu.org To: Andy Wingo Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Wed Jan 18 20:59:54 2012 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Rnbfm-0002sF-LO for guile-devel@m.gmane.org; Wed, 18 Jan 2012 20:59:54 +0100 Original-Received: from localhost ([::1]:54694 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rnbfm-000187-A7 for guile-devel@m.gmane.org; Wed, 18 Jan 2012 14:59:54 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:36146) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rnbfg-000182-TP for guile-devel@gnu.org; Wed, 18 Jan 2012 14:59:53 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rnbff-0001Hf-Vo for guile-devel@gnu.org; Wed, 18 Jan 2012 14:59:48 -0500 Original-Received: from world.peace.net ([96.39.62.75]:37741) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rnbff-0001G3-TL for guile-devel@gnu.org; Wed, 18 Jan 2012 14:59:47 -0500 Original-Received: from c-98-216-245-176.hsd1.ma.comcast.net ([98.216.245.176] helo=yeeloong) by world.peace.net with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.69) (envelope-from ) id 1RnbfP-0000iw-RB; Wed, 18 Jan 2012 14:59:32 -0500 In-Reply-To: <87sjjdfj3c.fsf@pobox.com> (Andy Wingo's message of "Wed, 18 Jan 2012 10:36:23 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 96.39.62.75 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:13565 Archived-At: Andy Wingo writes: > On Tue 17 Jan 2012 22:02, Mark H Weaver writes: > >> Therefore, the R5RS leaves no possible way for a complaint `eval' to >> restore the previous value of (current-module) after evaluation. >> Indeed, this is prohibited at a semantic level. > > FWIW, Racket circumvents this problem nicely, with what they call > "continuation marks". We might be able to reuse their strategy in our > with-fluids implementation. I don't see how continuation marks could solve this problem. They avoid adding more frames to the stack, but that's not enough. The R5RS says: A Scheme implementation is properly tail-recursive if it supports an unbounded number of active tail calls. A call is _active_ if the called procedure may still return. Therefore, even if you save the old value of (current-module) cleverly somewhere other than the stack, these old values would still in general use O(n) space, where N is the number of active calls to `eval'. On the other hand, if `eval' stores the saved (current-module) within the continuation outside of `eval', overwriting whatever value might already be stored there (thus avoiding the O(n) problem), this would be incorrect, because that outer continuation might have been stored somewhere, and it should _not_ restore (current-module). Fundamentally, if `eval' wishes to restore the former (current-module) after evaluation of the expression, then the inner continuation of the expression _must_ be semantically different than `eval's outer continuation: the inner one _must_ restore (current-module), and the outer one _must_ _not_ modify (current-module). Or am I missing something? Thanks, Mark