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.bugs Subject: bug#14164: letrec: detect illegal accesses to vars before entering body Date: Wed, 10 Apr 2013 05:25:20 -0400 Message-ID: <87li8qbuv3.fsf@tines.lan> References: <877gkcuxi7.fsf@karetnikov.org> <87bo9oe14d.fsf@tines.lan> <87mwt8p5u5.fsf@karetnikov.org> <87wqsbd57s.fsf@tines.lan> <874nffobys.fsf@karetnikov.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1365585985 18042 80.91.229.3 (10 Apr 2013 09:26:25 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 10 Apr 2013 09:26:25 +0000 (UTC) Cc: 14164@debbugs.gnu.org To: Nikita Karetnikov Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Wed Apr 10 11:26:29 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 1UPrIS-0001RE-3Q for guile-bugs@m.gmane.org; Wed, 10 Apr 2013 11:26:28 +0200 Original-Received: from localhost ([::1]:39823 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UPrIR-0000sz-N5 for guile-bugs@m.gmane.org; Wed, 10 Apr 2013 05:26:27 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:37484) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UPrIN-0000st-79 for bug-guile@gnu.org; Wed, 10 Apr 2013 05:26:24 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UPrIL-00064R-TV for bug-guile@gnu.org; Wed, 10 Apr 2013 05:26:23 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:38963) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UPrIL-00064N-Pq for bug-guile@gnu.org; Wed, 10 Apr 2013 05:26:21 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1UPrLv-0008NG-PX for bug-guile@gnu.org; Wed, 10 Apr 2013 05:30:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Mark H Weaver Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-guile@gnu.org Resent-Date: Wed, 10 Apr 2013 09:30:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 14164 X-GNU-PR-Package: guile X-GNU-PR-Keywords: Original-Received: via spool by 14164-submit@debbugs.gnu.org id=B14164.136558616631807 (code B ref 14164); Wed, 10 Apr 2013 09:30:03 +0000 Original-Received: (at 14164) by debbugs.gnu.org; 10 Apr 2013 09:29:26 +0000 Original-Received: from localhost ([127.0.0.1]:43072 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UPrLG-0008GX-M4 for submit@debbugs.gnu.org; Wed, 10 Apr 2013 05:29:25 -0400 Original-Received: from world.peace.net ([96.39.62.75]:36422) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UPrLB-0008GB-C2 for 14164@debbugs.gnu.org; Wed, 10 Apr 2013 05:29:18 -0400 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 1UPrHT-0003kC-O9; Wed, 10 Apr 2013 05:25:27 -0400 In-Reply-To: <874nffobys.fsf@karetnikov.org> (Nikita Karetnikov's message of "Tue, 09 Apr 2013 21:22:51 +0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (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:7082 Archived-At: Nikita Karetnikov writes: >> I'll fix the manual. > > Thanks. > > So what's the difference between 'letrec' and 'letrec*', then? I fail > to grasp it. The difference is that in 'letrec*', the initializers are guaranteed to be evaluated in order, and they are allowed to access earlier bindings before entering the body. In 'letrec', the order in which the initializers are evaluated is unspecified, and they are *not* allowed to access earlier bindings. > Could you add a relevant example to the manual? The example given in the manual under 'letrec*' was basically correct. The only problem was that it shouldn't have claimed that an error would be reported to the user. Here's the change I made to the manual: --8<---------------cut here---------------start------------->8--- index 5763f36..e3a9918 100644 (file) --- a/doc/ref/api-binding.texi +++ b/doc/ref/api-binding.texi @@ -218,9 +218,9 @@ variables. @lisp (letrec ((a 42) - (b (+ a 10))) + (b (+ a 10))) ;; Illegal access (* a b)) -@result{} ;; Error: unbound variable: a +;; The behavior of the expression above is unspecified (letrec* ((a 42) (b (+ a 10))) (* a b)) @result{} 2184 @end lisp --8<---------------cut here---------------end--------------->8--- >> When the standard (or the manual) says "the result is unspecified", that >> means that some value will be returned, but that value could be >> anything. > > Just to clarify: When the standard says "unspecified," I can read it as > "it's up to the particular implementation (e.g., Guile)," right? Yes, but keep in mind that there's no guarantee that the results will be consistent from one evaluation to the next, even within a particular implementation. For example, the 'letrec' above could return a random number each time it is run, or even crash randomly, though that would clearly be undesirable and we would seek to avoid that in Guile. Regards, Mark