GNU bug report logs - #14164
letrec: detect illegal accesses to vars before entering body

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: guile; Severity: wishlist; Reported by: Nikita Karetnikov <nikita@HIDDEN>; dated Tue, 9 Apr 2013 04:43:02 UTC; Maintainer for guile is bug-guile@HIDDEN.

Message received at 14164 <at> debbugs.gnu.org:


Received: (at 14164) by debbugs.gnu.org; 12 Apr 2013 08:47:10 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Apr 12 04:47:10 2013
Received: from localhost ([127.0.0.1]:46902 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1UQZdV-0005LD-SW
	for submit <at> debbugs.gnu.org; Fri, 12 Apr 2013 04:47:10 -0400
Received: from xanadu.aquilenet.fr ([88.191.123.111]:51619)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <ludo@HIDDEN>) id 1UQZdR-0005Kh-7c
	for 14164 <at> debbugs.gnu.org; Fri, 12 Apr 2013 04:47:07 -0400
Received: from localhost (localhost [127.0.0.1])
	by xanadu.aquilenet.fr (Postfix) with ESMTP id 73DE6F3E;
	Fri, 12 Apr 2013 10:43:09 +0200 (CEST)
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 uHOZrQUn78Uc; Fri, 12 Apr 2013 10:43:09 +0200 (CEST)
Received: from pluto (reverse-83.fdn.fr [80.67.176.83])
	by xanadu.aquilenet.fr (Postfix) with ESMTPSA id 04DC2BB;
	Fri, 12 Apr 2013 10:43:08 +0200 (CEST)
From: ludo@HIDDEN (Ludovic =?utf-8?Q?Court=C3=A8s?=)
To: Mark H Weaver <mhw@HIDDEN>
Subject: Re: bug#14164: letrec: detect illegal accesses to vars before
	entering body
References: <877gkcuxi7.fsf@HIDDEN> <87bo9oe14d.fsf@HIDDEN>
	<87mwt8p5u5.fsf@HIDDEN> <87wqsbd57s.fsf@HIDDEN>
	<874nffobys.fsf@HIDDEN> <87li8qbuv3.fsf@HIDDEN>
X-URL: http://www.fdn.fr/~lcourtes/
X-Revolutionary-Date: 23 Germinal 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
Date: Fri, 12 Apr 2013 10:43:08 +0200
In-Reply-To: <87li8qbuv3.fsf@HIDDEN> (Mark H. Weaver's message of "Wed, 10
	Apr 2013 05:25:20 -0400")
Message-ID: <87ppy09m1v.fsf@HIDDEN>
User-Agent: Gnus/5.130005 (Ma Gnus v0.5) Emacs/24.3 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 1.5 (+)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has
 identified this incoming email as possible spam.  The original message
 has been attached to this so you can view it (if it isn't spam) or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 
 Content preview:  Mark H Weaver <mhw@HIDDEN> skribis: > @lisp > (letrec
   ((a 42) > - (b (+ a 10))) > + (b (+ a 10))) ;; Illegal access > (* a b)) Please
    change it to “invalid access”. Nothing illegal here. ;-) [...] 
 
 Content analysis details:   (1.5 points, 10.0 required)
 
  pts rule name              description
 ---- ---------------------- --------------------------------------------------
  0.7 SPF_SOFTFAIL           SPF: sender does not match SPF record (softfail)
  0.8 BAYES_50               BODY: Bayes spam probability is 40 to 60%
                             [score: 0.4705]
X-Debbugs-Envelope-To: 14164
Cc: 14164 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.13
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: 0.7 (/)

Mark H Weaver <mhw@HIDDEN> skribis:

>  @lisp
>  (letrec ((a 42)
> -         (b (+ a 10)))
> +         (b (+ a 10)))  ;; Illegal access
>    (* a b))

Please change it to =E2=80=9Cinvalid access=E2=80=9D.  Nothing illegal here=
.  ;-)

Ludo=E2=80=99.




Information forwarded to bug-guile@HIDDEN:
bug#14164; Package guile. Full text available.

Message received at 14164 <at> debbugs.gnu.org:


Received: (at 14164) by debbugs.gnu.org; 10 Apr 2013 09:29:26 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Apr 10 05:29:26 2013
Received: from localhost ([127.0.0.1]:43072 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1UPrLG-0008GX-M4
	for submit <at> debbugs.gnu.org; Wed, 10 Apr 2013 05:29:25 -0400
Received: from world.peace.net ([96.39.62.75]:36422)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <mhw@HIDDEN>) id 1UPrLB-0008GB-C2
	for 14164 <at> debbugs.gnu.org; Wed, 10 Apr 2013 05:29:18 -0400
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 <mhw@HIDDEN>)
	id 1UPrHT-0003kC-O9; Wed, 10 Apr 2013 05:25:27 -0400
From: Mark H Weaver <mhw@HIDDEN>
To: Nikita Karetnikov <nikita@HIDDEN>
Subject: Re: bug#14164: letrec: detect illegal accesses to vars before
	entering body
References: <877gkcuxi7.fsf@HIDDEN> <87bo9oe14d.fsf@HIDDEN>
	<87mwt8p5u5.fsf@HIDDEN> <87wqsbd57s.fsf@HIDDEN>
	<874nffobys.fsf@HIDDEN>
Date: Wed, 10 Apr 2013 05:25:20 -0400
In-Reply-To: <874nffobys.fsf@HIDDEN> (Nikita Karetnikov's message of
	"Tue, 09 Apr 2013 21:22:51 +0400")
Message-ID: <87li8qbuv3.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 14164
Cc: 14164 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.13
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -1.9 (-)

Nikita Karetnikov <nikita@HIDDEN> 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




Information forwarded to bug-guile@HIDDEN:
bug#14164; Package guile. Full text available.

Message received at 14164 <at> debbugs.gnu.org:


Received: (at 14164) by debbugs.gnu.org; 9 Apr 2013 17:24:02 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Apr 09 13:24:02 2013
Received: from localhost ([127.0.0.1]:42202 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1UPcH2-0001K9-Se
	for submit <at> debbugs.gnu.org; Tue, 09 Apr 2013 13:24:02 -0400
Received: from li305-5.members.linode.com ([178.79.168.5]:35473
	helo=cooksoni.karetnikov.org)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <nikita@HIDDEN>) id 1UPcGz-0001K0-Gy
	for 14164 <at> debbugs.gnu.org; Tue, 09 Apr 2013 13:23:59 -0400
From: Nikita Karetnikov <nikita@HIDDEN>
To: Mark H Weaver <mhw@HIDDEN>
Subject: Re: bug#14164: letrec: detect illegal accesses to vars before
	entering body
References: <877gkcuxi7.fsf@HIDDEN> <87bo9oe14d.fsf@HIDDEN>
	<87mwt8p5u5.fsf@HIDDEN> <87wqsbd57s.fsf@HIDDEN>
Date: Tue, 09 Apr 2013 21:22:51 +0400
In-Reply-To: <87wqsbd57s.fsf@HIDDEN> (Mark H. Weaver's message of "Tue, 09
	Apr 2013 12:44:07 -0400")
Message-ID: <874nffobys.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/signed; boundary="=-=-=";
	micalg=pgp-sha1; protocol="application/pgp-signature"
X-Spam-Score: 0.8 (/)
X-Debbugs-Envelope-To: 14164
Cc: 14164 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.13
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -0.5 (/)

--=-=-=

> I'll fix the manual.

Thanks.

So what's the difference between 'letrec' and 'letrec*', then?  I fail
to grasp it.  Could you add a relevant example to the manual?

> 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?

--=-=-=
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iQIcBAEBAgAGBQJRZE5vAAoJEM+IQzI9IQ38pmgP/3pdOAuqx/nyElkPbyvyOWOE
1Min18UipZk19NPMawCbISYl4UF3mnMIWSsfESs+e0yu5ht8XZ7FM0Wf5ozQDCbA
oKOn3Qdwr1CWlLPz1rZsohV9Lz05S5Ly5/p/DPw0Cr1IlbLBav31Syk3Ps0Wqi+A
Errb/OFOjJE5qdRqz8BDK22YFzJpRx8proW7+LpEGBNHHu5tYvRJH8pgKUdiofxw
zWF25l5QZ1lkBtSr7MCAQGaWt4Cp54lx4LBt1mNNkZZ90YM9S1RZrHW+zusOkeOz
n3Ml7dC+vT5MATZa86akgGRN5DMSychnp+Zk23IbhUNOuB6+nURryvUUIn1BwQBZ
/NJW34aCkZYM8B3dSAVRGTJhGSXGJvJVQUasJGQ2UuX81LUk7m+hQQU/xWgJJH7j
mycLoZ7DOUEUW1D/t2DD/ylSPOsDbBvpSZi+SV0CKE3Cuq8MMV0aH7uPlywZiI9B
WmpO12UOHrGokbmQcMwE+645vlnsh/ZXhMvIXTGc7Uxx0LqmHd0TD1Ucn4IZpQzc
TozupacoFiwiEPq1BJa3378i8Gckh+Iws1AKsofXzniz0owTPo48HH/nCRCvRGQr
BaFV7nbJqjfDD9mTQNZ9P7afHhNg4661BBIEsU/2U8uEg70QqU6ujhCQR+T6eeFq
hZVy9+OqZKFZVoi03DsW
=D7zK
-----END PGP SIGNATURE-----
--=-=-=--




Information forwarded to bug-guile@HIDDEN:
bug#14164; Package guile. Full text available.

Message received at 14164 <at> debbugs.gnu.org:


Received: (at 14164) by debbugs.gnu.org; 9 Apr 2013 16:48:05 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Apr 09 12:48:04 2013
Received: from localhost ([127.0.0.1]:42171 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1UPbiG-0000PT-Eu
	for submit <at> debbugs.gnu.org; Tue, 09 Apr 2013 12:48:04 -0400
Received: from world.peace.net ([96.39.62.75]:35637)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <mhw@HIDDEN>) id 1UPbiD-0000P1-Be
	for 14164 <at> debbugs.gnu.org; Tue, 09 Apr 2013 12:48:02 -0400
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 <mhw@HIDDEN>)
	id 1UPbeZ-00078a-Rp; Tue, 09 Apr 2013 12:44:16 -0400
From: Mark H Weaver <mhw@HIDDEN>
To: Nikita Karetnikov <nikita@HIDDEN>
Subject: Re: bug#14164: letrec: detect illegal accesses to vars before
	entering body
References: <877gkcuxi7.fsf@HIDDEN> <87bo9oe14d.fsf@HIDDEN>
	<87mwt8p5u5.fsf@HIDDEN>
Date: Tue, 09 Apr 2013 12:44:07 -0400
In-Reply-To: <87mwt8p5u5.fsf@HIDDEN> (Nikita Karetnikov's message of
	"Tue, 09 Apr 2013 10:37:38 +0400")
Message-ID: <87wqsbd57s.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 14164
Cc: 14164 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.13
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -1.9 (-)

Nikita Karetnikov <nikita@HIDDEN> writes:

>>> According to the manual [1], this snippet:
>>>
>>> (letrec ((a 42)
>>>          (b (+ a 10)))
>>>   (* a b))
>>>
>>> should return "Error: unbound variable: a."
>
>> The manual doesn't say anything nearly that specific.
>
> Either you missed it or I misunderstood this sentence.  So if you missed
> it, it can be found below 'syntax: letrec* bindings body'.

Oops!  You're right, of course.  Apologies for saying you were wrong.
I'll fix the manual.

>> In general, if the manual says you "may not" do something, or if the
>> R5RS says "it is an error", that means that if you do, the results are
>> unspecified.
>
> Are you talking about the result of 'letrec' or 'b'?  Anyway, why does
> it return 2184 if the results are unspecified?  Could you elaborate?

Well, first of all, I misspoke.  In this case, I should have said (as
the R5RS did) that "it is an error", which in Scheme-standard-speak
means "anything at all could happen".  This is different from "an error
is signaled" or "an error is raised" or "an exception is thrown" which
consitutes a promise to report an error.

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.

Although Guile includes a distinguished value shown as "*unspecified*",
which is often used in these cases, it is not always used.  In practice,
we use it when we can easily do so without imposing a runtime cost, as a
debugging aid.  However, it is not always used.

     Thanks,
       Mark




Information forwarded to bug-guile@HIDDEN:
bug#14164; Package guile. Full text available.

Message received at 14164 <at> debbugs.gnu.org:


Received: (at 14164) by debbugs.gnu.org; 9 Apr 2013 06:38:44 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Apr 09 02:38:44 2013
Received: from localhost ([127.0.0.1]:41080 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1UPSCX-0001B4-Jn
	for submit <at> debbugs.gnu.org; Tue, 09 Apr 2013 02:38:43 -0400
Received: from li305-5.members.linode.com ([178.79.168.5]:35465
	helo=cooksoni.karetnikov.org)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <nikita@HIDDEN>) id 1UPSCU-0001Au-3H
	for 14164 <at> debbugs.gnu.org; Tue, 09 Apr 2013 02:38:39 -0400
From: Nikita Karetnikov <nikita@HIDDEN>
To: Mark H Weaver <mhw@HIDDEN>
Subject: Re: bug#14164: letrec: detect illegal accesses to vars before
	entering body
References: <877gkcuxi7.fsf@HIDDEN> <87bo9oe14d.fsf@HIDDEN>
Date: Tue, 09 Apr 2013 10:37:38 +0400
In-Reply-To: <87bo9oe14d.fsf@HIDDEN> (Mark H. Weaver's message of "Tue, 09
	Apr 2013 01:14:58 -0400")
Message-ID: <87mwt8p5u5.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/signed; boundary="=-=-=";
	micalg=pgp-sha1; protocol="application/pgp-signature"
X-Spam-Score: 0.8 (/)
X-Debbugs-Envelope-To: 14164
Cc: 14164 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.13
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -0.5 (/)

--=-=-=

>> According to the manual [1], this snippet:
>>
>> (letrec ((a 42)
>>          (b (+ a 10)))
>>   (* a b))
>>
>> should return "Error: unbound variable: a."

> The manual doesn't say anything nearly that specific.

Either you missed it or I misunderstood this sentence.  So if you missed
it, it can be found below 'syntax: letrec* bindings body'.

> In general, if the manual says you "may not" do something, or if the
> R5RS says "it is an error", that means that if you do, the results are
> unspecified.

Are you talking about the result of 'letrec' or 'b'?  Anyway, why does
it return 2184 if the results are unspecified?  Could you elaborate?

--=-=-=
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iQIcBAEBAgAGBQJRY7c3AAoJEM+IQzI9IQ38BLYQAJ8o0caME9RdTUlXjGTx0Fx0
fMnsk9rdZ61Dyds7ifn24QXUvUNM9BFfAc6dZNTFgQm22h1aL4F+un9P5DE+KYXX
3smWLMqERkkvo/Hnl3HHFabpTGCxO1pDs3ZNl7Vl8EbD+zRa1fQUMyYuedUAi4F/
yscIJPAZphD69IpHGhpqxcpg40x5o99U37fnuARvxgtSc5tV2mPCufZeP8bZu1M2
430KQ1hH+4wyguZSnmDBdtA5fmvlDtatOaFuN1sO80+pZvpBfbxVs559aWlrQjO0
eSuBTRmkAJGs7qH74MwQaWpoti1Re+1O0RQtfIYsRKDhCuhw3IIw8YUBw0LXXk5Y
ELAIKO3gV+qhT9fgQ/295zOkzt2ouCxgtVutZZTM1JbNN3NOt8fZXyvTrInOyD6/
Uu4YvJVC9l2+6eVmlrjjlOb7zvtD9qTOR3grfIr0cmkYCmRJyGaiZ0R4mslfZgSd
8f6XtQvOB+4+4G0Ah5t7Po5UbXnclVAkgMhF+H4NsPDINbhyeUUZHfLJFdTtFea3
+4+MLAtyRy5uMACG7xoW2BLDABVC4aay3ohjtTCn7GZuX1q2CC6G5uHsjV2NxfRR
9H0CuC7mAX9Cm5rX8N/2f9Ew/MwNdjEfVj175Es3ivuBtPxZhaC9vV9jG6N5Wnbf
YCH2W1j2Z5IpKjGhQCrk
=iSk6
-----END PGP SIGNATURE-----
--=-=-=--




Information forwarded to bug-guile@HIDDEN:
bug#14164; Package guile. Full text available.

Message received at 14164 <at> debbugs.gnu.org:


Received: (at 14164) by debbugs.gnu.org; 9 Apr 2013 05:18:51 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Apr 09 01:18:51 2013
Received: from localhost ([127.0.0.1]:41053 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1UPQxG-0006kf-Hv
	for submit <at> debbugs.gnu.org; Tue, 09 Apr 2013 01:18:50 -0400
Received: from world.peace.net ([96.39.62.75]:34960)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <mhw@HIDDEN>) id 1UPQxE-0006kW-2Q
	for 14164 <at> debbugs.gnu.org; Tue, 09 Apr 2013 01:18:48 -0400
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 <mhw@HIDDEN>)
	id 1UPQtd-0005D6-UL; Tue, 09 Apr 2013 01:15:06 -0400
From: Mark H Weaver <mhw@HIDDEN>
To: Nikita Karetnikov <nikita@HIDDEN>
Subject: Re: bug#14164: letrec: detect illegal accesses to vars before
	entering body
References: <877gkcuxi7.fsf@HIDDEN>
Date: Tue, 09 Apr 2013 01:14:58 -0400
In-Reply-To: <877gkcuxi7.fsf@HIDDEN> (Nikita Karetnikov's message of
	"Tue, 09 Apr 2013 08:41:04 +0400")
Message-ID: <87bo9oe14d.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.8 (/)
X-Debbugs-Envelope-To: 14164
Cc: 14164 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.13
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -1.9 (-)

Nikita Karetnikov <nikita@HIDDEN> writes:

> According to the manual [1], this snippet:
>
> (letrec ((a 42)
>          (b (+ a 10)))
>   (* a b))
>
> should return "Error: unbound variable: a."

The manual doesn't say anything nearly that specific.  It says "Note
that while the init expressions may refer to the new variables, they may
not access their values."  The R5RS says "it must be possible to
evaluate each <init> without assigning or referring to the value of any
<variable>.  If this restriction is violated, then it is an error."

In general, if the manual says you "may not" do something, or if the
R5RS says "it is an error", that means that if you do, the results are
unspecified.  It does not constitute a promise to report an error if you
do.

I agree that we should ideally report errors such as this, but this is
not a bug, but rather a wishlist item.  Note that generating code that
detects programmer errors such as this may carry a non-trivial runtime
cost, so we might need to provide a distinct compilation mode that
inserts such debugging checks.

This is on my TODO list, but I wouldn't hold your breath :)

    Regards,
      Mark




Information forwarded to bug-guile@HIDDEN:
bug#14164; Package guile. Full text available.
Severity set to 'wishlist' from 'normal' Request was from Mark H Weaver <mhw@HIDDEN> to control <at> debbugs.gnu.org. Full text available.
Changed bug title to 'letrec: detect illegal accesses to vars before entering body' from ''letrec' allows to refer to the values of previously bound variables' Request was from Mark H Weaver <mhw@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 9 Apr 2013 04:42:15 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Apr 09 00:42:15 2013
Received: from localhost ([127.0.0.1]:41026 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1UPQNr-0005pe-H0
	for submit <at> debbugs.gnu.org; Tue, 09 Apr 2013 00:42:15 -0400
Received: from eggs.gnu.org ([208.118.235.92]:41945)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <nikita@HIDDEN>) id 1UPQNn-0005pV-6z
	for submit <at> debbugs.gnu.org; Tue, 09 Apr 2013 00:42:12 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <nikita@HIDDEN>) id 1UPQKG-0007NB-Nn
	for submit <at> debbugs.gnu.org; Tue, 09 Apr 2013 00:38:35 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_MIME_NO_TEXT,
	T_TVD_MIME_NO_HEADERS autolearn=disabled version=3.3.2
Received: from lists.gnu.org ([208.118.235.17]:36484)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <nikita@HIDDEN>) id 1UPQKG-0007N7-L5
	for submit <at> debbugs.gnu.org; Tue, 09 Apr 2013 00:38:32 -0400
Received: from eggs.gnu.org ([208.118.235.92]:53281)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <nikita@HIDDEN>) id 1UPQKD-0003zp-1u
	for bug-guile@HIDDEN; Tue, 09 Apr 2013 00:38:32 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <nikita@HIDDEN>) id 1UPQKA-0007MK-NG
	for bug-guile@HIDDEN; Tue, 09 Apr 2013 00:38:28 -0400
Received: from li305-5.members.linode.com ([178.79.168.5]:41263
	helo=cooksoni.karetnikov.org) by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <nikita@HIDDEN>) id 1UPQKA-0007MB-Hf
	for bug-guile@HIDDEN; Tue, 09 Apr 2013 00:38:26 -0400
From: Nikita Karetnikov <nikita@HIDDEN>
To: bug-guile@HIDDEN
Subject: 'letrec' allows to refer to the values of previously bound variables
Date: Tue, 09 Apr 2013 08:41:04 +0400
Message-ID: <877gkcuxi7.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/signed; boundary="=-=-=";
	micalg=pgp-sha1; protocol="application/pgp-signature"
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic]
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 208.118.235.17
X-Spam-Score: -4.2 (----)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.13
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -6.9 (------)

--=-=-=

According to the manual [1], this snippet:

(letrec ((a 42)
         (b (+ a 10)))
  (* a b))

should return "Error: unbound variable: a."  But it returns 2184 in
Guile 2.0.7.  Either there is a bug in the manual or 'letrec' doesn't
work properly.

[1] https://gnu.org/software/guile/manual/guile.html#Local-Bindings

--=-=-=
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iQIcBAEBAgAGBQJRY5vkAAoJEM+IQzI9IQ381UkP/jjarFroZE8xdeYYsrPTaqjn
onCQPyNDLwmKGsonPv7h+NtWzGV4hab6hWtNnqSL6t6YyOPBAJmkYXKR/MXAtlB2
MpEZE05LvF74EDyWTn7CYvHN2KH2Gr2ufqKbJRr+pSh1xDv2swTtoUxTkICR65zb
U+45U8o+aWSNqbDpsIHHMaoyVTEZpqLcHwHMSI/vvaUwbnfTQ9vdjE8Ma/aqOoOz
qhzlHQ+VpBQ5p5hbsWgceQnycOkCutIP1kuAVK04Bn3PqnpKcebE0LDAymEWgFak
qNlYJgLwLOUCDz90fRSyz6V/Tuzqlbftpzijdh9syBifXUTscHCbP1oRB6XM6kVZ
Q5PLPT0upxZoxcaSZ1jEO7FW8aNp7vWWylVH4NXTDJsiPoh7kVmPpc3BiKOjrcFk
abf9Gk8ojCFd/WCVZ7gHxA+hFRCFbgyG5QmYIBAGRXjr6Va2kJBDCnF5pagU9bws
N9vbnmFkshj8uY2H0nFnaiGzOcTgwoZ89MjmBNFj9XTIJuu5f6p04w2fcH7xaILb
aEVW1IWZuKtugVf+/Sv9w3XHpDvTrshe3hq8LIHXnT0hvY9pBUiWmrq97gGpG8bA
SjGVeTTSD/Y6ojSRk3cO6+Rn2WdPM1U2zZaeTpyujGig5j4Utc7nOigka945oasz
P5IMbntWlPXdnvyku9jd
=793m
-----END PGP SIGNATURE-----
--=-=-=--




Acknowledgement sent to Nikita Karetnikov <nikita@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-guile@HIDDEN. Full text available.
Report forwarded to bug-guile@HIDDEN:
bug#14164; Package guile. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Fri, 31 Oct 2014 17:00:04 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.