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: CPS Update Date: Sat, 23 Feb 2013 02:49:30 -0500 Message-ID: <871uc78o6t.fsf@tines.lan> References: <871ucgrryo.fsf@tines.lan> <87txpcq7nx.fsf@tines.lan> <871uccgtqo.fsf@tines.lan> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1361605799 5630 80.91.229.3 (23 Feb 2013 07:49:59 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 23 Feb 2013 07:49:59 +0000 (UTC) Cc: guile-devel To: William ML Leslie Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Sat Feb 23 08:50:22 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 1U99sE-0003o6-1M for guile-devel@m.gmane.org; Sat, 23 Feb 2013 08:50:22 +0100 Original-Received: from localhost ([::1]:57719 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U99rt-0008BD-Ek for guile-devel@m.gmane.org; Sat, 23 Feb 2013 02:50:01 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:36188) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U99rp-0008An-6R for guile-devel@gnu.org; Sat, 23 Feb 2013 02:50:00 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U99rn-0001xt-L2 for guile-devel@gnu.org; Sat, 23 Feb 2013 02:49:57 -0500 Original-Received: from world.peace.net ([96.39.62.75]:57707) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U99rn-0001w2-GI for guile-devel@gnu.org; Sat, 23 Feb 2013 02:49:55 -0500 Original-Received: from 209-6-91-212.c3-0.smr-ubr1.sbo-smr.ma.cable.rcn.com ([209.6.91.212] helo=tines.lan) by world.peace.net with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1U99rW-0001ED-8Y; Sat, 23 Feb 2013 02:49:38 -0500 In-Reply-To: (William ML Leslie's message of "Fri, 22 Feb 2013 19:25:43 +1100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x 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:15809 Archived-At: William ML Leslie writes: > On 20 February 2013 03:21, Mark H Weaver wrote: >> (define (func x) >> (let ((r (my-special-function x))) >> (+ x 2 r))) >> >> Here, (my-special-function x) must be evaluated before evaluating '+'. >> Evaluating '+' means to fetch the value stored in the location denoted >> by '+'. Therefore, if '+' is rebound during the call to >> 'my-special-function', then the new binding for '+' must be used. >> >> This is a case where on-stack-replacement is needed to implement the >> correct semantics. >> >> To summarize, when you rebind a function 'foo', it is not the existing >> activation records for 'foo' that you need to worry about. Instead, you >> need to worry about existing activation records for all compiled >> procedures 'bar' that incorporated assumptions about 'foo'. > > Recompiling every procedure that uses + when somebody binds it means > compiling a lot of code that probably isn't going to be used. More > likely, if + has been inlined here, the compiler will have to emit a > guard that checks inlining assumptions as the start of the let body. I'm afraid this isn't good enough. Even if one ignores the possibility of multiple threads, checks would have to be added not just at the start of each let body, but also upon return from every procedure that might rebind '+' or capture its continuation. This includes all procedures accessed through toplevel/module bindings. Therefore, I repeat my initial assertion that this is a can of worms. I'd like to see it implemented in Guile some day, but it's a big job. Regards, Mark