From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?Linus_Bj=C3=B6rnstam?= Newsgroups: gmane.lisp.guile.user Subject: Re: letrec semantics Date: Thu, 01 Dec 2022 10:30:05 +0100 Message-ID: References: <87sfi379eb.fsf@soeven.de> Mime-Version: 1.0 Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="28009"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Cyrus-JMAP/3.7.0-alpha0-1115-g8b801eadce-fm-20221102.001-g8b801ead To: "Alexander Asteroth" , guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Thu Dec 01 10:31:23 2022 Return-path: Envelope-to: guile-user@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p0fua-00072y-8s for guile-user@m.gmane-mx.org; Thu, 01 Dec 2022 10:31:21 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p0fuH-000114-4o; Thu, 01 Dec 2022 04:31:01 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p0ftp-0000ts-53 for guile-user@gnu.org; Thu, 01 Dec 2022 04:30:35 -0500 Original-Received: from wout2-smtp.messagingengine.com ([64.147.123.25]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p0ftn-0002I2-7E for guile-user@gnu.org; Thu, 01 Dec 2022 04:30:32 -0500 Original-Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 19716320096F; Thu, 1 Dec 2022 04:30:27 -0500 (EST) Original-Received: from imap51 ([10.202.2.101]) by compute2.internal (MEProxy); Thu, 01 Dec 2022 04:30:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.se; h= cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1669887026; x= 1669973426; bh=ssebpvZlvC/srcAfJCYZKJDozifQ5Z9RWnAInguoVGg=; b=H zhY5e+ifCHaSGSS4n4hviT37YVzoMbYBaBUd7s/IN4pVfrQ5GEulVNZoTX+P5exg 9LBFPHZ8+9jroNJV2Ql/cg/64WC7Yc9GNmCvcSKkeipKO1vjAEnNRHSpm3RAj8GU UiwO+BnofvTwWCDA7OAkiUi0OD+Pldp7jbeU1Qnbu5DCKZhdfxmVWC+1QET8pOUY lOM9imqwPqWdAIjiaJOMgihcSuIseNqrjb+jrpydMhHbjyaIxTwjdzp9bB9Pvfq1 MnK0DIHGPhrlRzP8xrNtWy1jdIuGj7KtmrAZ0Euo9q1421+Efft8fmVWU3edtY4F UVfDdaB8rlls8TQlvp1JA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:date:feedback-id:feedback-id:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1669887026; x=1669973426; bh=s sebpvZlvC/srcAfJCYZKJDozifQ5Z9RWnAInguoVGg=; b=gxdWZ8CTagew58/Lh Y6e2UxGcu/kYm6gADrvEuVvht2f7kGz5JfAhcKQqS56JDFbqn/HcSSUvQG/vQxr5 KlQXFMsHc98Esuxpk80oo0W4vWusGx9oCr8sRwFca/d13pyYwWQNCw9ukJCYfPf2 TDFTDS/hsHCpb+6eWPnCnXqsh/fOzuZH+1z/d7J7OAmtjSkofqY5SL+SO97Wf2Nc pZk7VdFG+SbBdQaSedDdq7kedKgCQJnzq5hcpbtKMSRh0fwZOAEiKWVjYQm3vP6J 5HisqUoxegC6Nd/VN782PQ6ur14VT2N43fedqd+EkQlIqppNHZisXEZw7ls+hbZw 6I0xw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrtdehgddtgecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefofgggkfgjfhffhffvufgtgfesthhqredtreerjeenucfhrhhomhepnfhinhhu shcuuehjnphrnhhsthgrmhcuoehlihhnuhhsrdhinhhtvghrnhgvthesfhgrshhtmhgrih hlrdhsvgeqnecuggftrfgrthhtvghrnhepfeffhfelfeeuvdelfeegffevteegiedtvdff hfelhfehgfekueehieelgeduleejnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrg hmpehmrghilhhfrhhomheplhhinhhushdrihhnthgvrhhnvghtsehfrghsthhmrghilhdr shgv X-ME-Proxy: Feedback-ID: i57f3436d:Fastmail Original-Received: by mailuser.nyi.internal (Postfix, from userid 501) id 4F43CB60086; Thu, 1 Dec 2022 04:30:26 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface In-Reply-To: <87sfi379eb.fsf@soeven.de> Received-SPF: pass client-ip=64.147.123.25; envelope-from=linus.internet@fastmail.se; helo=wout2-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.lisp.guile.user:18757 Archived-At: Guile implements letrec using letrec*, which most schemes always did, bu= t it wasn't specified due to people wanting to leave possible optimisati= ons on the table.=20 The order of letrec is unspecified and schemes are allowed to do whateve= r order they like. Guile uses the algorithm described in "fixing letrec(= reloaded)". --=20 Linus Bj=C3=B6rnstam On Mon, 28 Nov 2022, at 09:33, Alexander Asteroth wrote: > Dear all, > > I know this topic has been discussed in the past. I found at least one > discussion in 2003 in guile-user@gnu.org which in the end referred to > even earlier discussions in comp.lang.scheme. But still I'm confused > about this and wonder if someone could help with this or point me to a > discussion that resolves the following issue. > > In R5RS it sais about letrec: > >>Semantics: The =E3=80=88variable=E3=80=89s are bound to fresh locations >> holding undefined values, the =E3=80=88init=E3=80=89s are evaluated i= n the >> resulting environment (in some unspecified order), each >> =E3=80=88variable=E3=80=89 is assigned to the result of the correspon= ding >> =E3=80=88init=E3=80=89, the =E3=80=88body=E3=80=89 is evaluated in th= e resulting environmet [...] > > As I (and others) understand=20 > >> scheme@(guile-user)> (letrec ((b a)(a 7)) b) >> $1 =3D 7 > > should be equivalent (of course in a new scope) to: > >> scheme@(guile-user)> (define b #nil) >> scheme@(guile-user)> (define a #nil) >> scheme@(guile-user)> (set! b a) >> scheme@(guile-user)> (set! a 7) >> scheme@(guile-user)> b >> $2 =3D #nil > > but obviously it is't. Why is b assigned to a's reference rather than > it's value in letrec? ... and would it be a correct implementation of > R5RS-letrec to return #nil from the letrec above? > > Cheers, > Alex