From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Israelsson Tampe Newsgroups: gmane.lisp.guile.devel Subject: Fwd: Fwd: [Patch] definitions in when, unless, do as well as in cond- and case-clauses Date: Fri, 4 Feb 2022 22:40:38 +0100 Message-ID: References: <7f58438c-f2fb-49b6-b7b0-22054fde6277@www.fastmail.com> <38a7683ab39f412cd6f5b137d2f6ebd6f5410c5e.camel@telenet.be> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000b09f4d05d7381a09" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40476"; mail-complaints-to="usenet@ciao.gmane.io" To: guile-devel Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Fri Feb 04 22:42:22 2022 Return-path: Envelope-to: guile-devel@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 1nG6LV-000AJl-U3 for guile-devel@m.gmane-mx.org; Fri, 04 Feb 2022 22:42:22 +0100 Original-Received: from localhost ([::1]:41068 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nG6LU-0003WG-E3 for guile-devel@m.gmane-mx.org; Fri, 04 Feb 2022 16:42:20 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:35826) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nG6K7-0003TX-8v for guile-devel@gnu.org; Fri, 04 Feb 2022 16:40:56 -0500 Original-Received: from [2607:f8b0:4864:20::1035] (port=41519 helo=mail-pj1-x1035.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nG6K3-0007yX-QH for guile-devel@gnu.org; Fri, 04 Feb 2022 16:40:54 -0500 Original-Received: by mail-pj1-x1035.google.com with SMTP id t12-20020a17090a3e4c00b001b87b6fd18aso391118pjm.0 for ; Fri, 04 Feb 2022 13:40:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=3DlxvAKyPCEVvuSZ676iigKEzMXz+0amFEJQLQPEZ7Q=; b=T/LU/VIxtEztr47DsTrcMpqn12ugKynFD59wdA40cjcsEY9ryL4iLOtVtWk197gIdp YF+HRu2qGZMYf/V0KWIe4GflInI4D25BzvOsNzli7cQMhGQuNSnE4sPYOjQDdx9u6yKF MnzC6ZZ8ruEJu0xqDkJn7zbYg0S7Bl88P1rj3LBbYafzDFOAhE1AfEIrV9kSzyiGJB4v 1st6un02MDUvFHZXIFrjR3NA4J9oUaTbq3RsMCxhE6kyUJtKdBHXwNzIRVSkwZQHfOFo m8PvCSV6bcvMGUG6Ms5iK2+V7j3hi9mEiU+6fNWOL/NfvJAKtVxntUxIk4FDjfMAo/ZT udow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=3DlxvAKyPCEVvuSZ676iigKEzMXz+0amFEJQLQPEZ7Q=; b=rLFIfjeq2z00FfVZmSCep9EelR6tqnpzQq1adHLLE056XGrgiFGAB4qcv5yexLElZA y6n93KaoEkMk1h6folTW2xX42qQplcK+mpLWMjvSVChJUHCgrLPRxVpifolTCGsz2zX0 un0A0dFFxMlgRktGBzz6SCUbohmT5R6ssjSl728J1O8s5RLBle32AFFGQGZk7Y7CABOd 9StTu/RMBn1JvZ7CnLAXJc3WyBPyt80MlrUhEC2X6+SzmCDjn/Q5AeCd3t4vHpda22dd o6MXB0Zjp4X7uyfwVmuDu3smf81Dd6n1D89KmuDqKAQE3U5v2a4LQDJf51hnOyBKfMqZ 2QSw== X-Gm-Message-State: AOAM530dEox5SDG1HI/zNVZnEnzHYTnwvTpgrfFabaTihOCPs5XsxxnX 3+f2hqsAo8XGpyiL8KFML/mJo+qrJPnzjs5+OgKQBBnW X-Google-Smtp-Source: ABdhPJzswPcFF9iSpwX8wUy2OQNJ9GtBw0bpZiuoexIBH5d7kEoYH1NCl3nl4A0FU2XmHc13ZuQfIKEHFW/pTfr/UDw= X-Received: by 2002:a17:903:234e:: with SMTP id c14mr5193947plh.50.1644010849475; Fri, 04 Feb 2022 13:40:49 -0800 (PST) In-Reply-To: X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::1035 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::1035; envelope-from=stefan.itampe@gmail.com; helo=mail-pj1-x1035.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, HTML_MESSAGE=0.001, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.29 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-mx.org@gnu.org Original-Sender: "guile-devel" Xref: news.gmane.io gmane.lisp.guile.devel:21068 Archived-At: --000000000000b09f4d05d7381a09 Content-Type: text/plain; charset="UTF-8" ---------- Forwarded message --------- From: Stefan Israelsson Tampe Date: Fri, Feb 4, 2022 at 10:40 PM Subject: Re: Fwd: [Patch] definitions in when, unless, do as well as in cond- and case-clauses To: Maxime Devos I tested and yes you are right, in guile conditionals do not have this property and similarly, all other directives I could find does not work, but because scheme has macros this is not super important. So then we should fix this to replace the definition from, (if p x y) to (if p (let () x) (let () y)) And then all other conditional, that is expressed as macros from if have the correct a let binding if we want this. This change will make new code non compilable by old guile's but that is not a huge issue, just make a macro package that you introduce conditionally to your project and recompile. The good thing is namely that issues will brake at compile time and not through some mysterious run time bug. Anyhow conditional defining vars is a common theme in other languages so I think it was kind of natural to implement if as it was done. Regards Stefan On Fri, Feb 4, 2022 at 9:58 PM Maxime Devos wrote: > Stefan Israelsson Tampe schreef op vr 04-02-2022 om 21:11 [+0100]: > > using an implicit let in conditionals are bad in that you cannot > > escape from the let form which means that you loos > > conditional defines for example in the toplevel. e.g. [...] > > While old versions of Guile (Guile 1.8?) did support conditional > defines on the top-level, new versions of Guile (Guile 2.0 and later) > don't: > > (if #true > (define x 'foo) > (define x 'bar)) > > While compiling expression: > Syntax error: > unknown file:2:4: definition in expression context, where definitions > are not allowed, in form (define x (quote foo)) > > The following still works though of course: > > (define x (if #true 'foo 'bar)) > > So for the current version of Guile (3.0.X), there don't appear to be > backwards-compatibility problems in this area. > > Greetings, > Maxime. > --000000000000b09f4d05d7381a09 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


---------- Forwarded message ---------
From: Stefan Israelsson Tampe <stefan.itampe@= gmail.com>
Date: Fri, Feb 4, 2022 at 10:40 PM
Subject: = Re: Fwd: [Patch] definitions in when, unless, do as well as in cond- and ca= se-clauses
To: Maxime Devos <maximedevos@telenet.be>


I tested= and yes you are right, in guile conditionals do not have this property and= similarly,=C2=A0 all other=C2=A0directives I could find=C2=A0
does not= work, but because scheme has macros this is not super important. So then w= e should fix this to replace the definition
from,
(i= f p x y)=C2=A0

to

(if p (= let () x) (let () y))

And then all other condition= al, that is expressed as macros from if have the correct a let binding if w= e want this. This change will=C2=A0
make new code non compilable = by old guile's but that is not a huge issue, just make a macro package = that you introduce conditionally
to your project and recompile. T= he good thing is namely that issues will brake at compile time and not thro= ugh some mysterious=C2=A0
run time bug.

= Anyhow conditional defining vars is a common theme in other languages so I = think it was kind of natural to implement if as it was done.

=


Regards
Stefan=C2=A0

On Fri, Feb 4, 2022 at 9:58 PM Maxime Devos <maximedevos@telenet.be= > wrote:
Stef= an Israelsson Tampe schreef op vr 04-02-2022 om 21:11 [+0100]:
> using an implicit let in conditionals=C2=A0are bad in that you cannot<= br> > escape=C2=A0from the let form which means that you loos
> conditional=C2=A0defines for example in the toplevel. e.g. [...]

While old versions of Guile (Guile 1.8?) did support conditional
defines on the top-level, new versions of Guile (Guile 2.0 and later)
don't:

(if #true
=C2=A0 =C2=A0 (define x 'foo)
=C2=A0 =C2=A0 (define x 'bar))

While compiling expression:
Syntax error:
unknown file:2:4: definition in expression context, where definitions
are not allowed, in form (define x (quote foo))

The following still works though of course:

(define x (if #true 'foo 'bar))

So for the current version of Guile (3.0.X), there don't appear to be backwards-compatibility problems in this area.

Greetings,
Maxime.
--000000000000b09f4d05d7381a09--