From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Damien Mattei Newsgroups: gmane.lisp.guile.devel Subject: Re: new function Date: Thu, 23 Sep 2021 23:53:17 +0200 Message-ID: References: <147c2fb4-75d6-7cf6-4f4a-4edd996b0a4a@gmail.com> <9c058f24-5b15-417a-17ff-10bc13fed12d@gmail.com> <8dbf9ce5-f01c-94ae-40a2-0fae688f856b@gmail.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000309c9305ccb0a9aa" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="31257"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Jean-Paul Roy , guile-devel To: Taylan Kammer Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Thu Sep 23 23:53:44 2021 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 1mTWf2-0007vY-Be for guile-devel@m.gmane-mx.org; Thu, 23 Sep 2021 23:53:44 +0200 Original-Received: from localhost ([::1]:38944 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTWf1-0005LJ-BC for guile-devel@m.gmane-mx.org; Thu, 23 Sep 2021 17:53:43 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48858) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mTWeq-0005Kv-DV for guile-devel@gnu.org; Thu, 23 Sep 2021 17:53:32 -0400 Original-Received: from mail-io1-xd34.google.com ([2607:f8b0:4864:20::d34]:37429) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mTWeo-0005qw-60 for guile-devel@gnu.org; Thu, 23 Sep 2021 17:53:32 -0400 Original-Received: by mail-io1-xd34.google.com with SMTP id s20so10083757ioa.4 for ; Thu, 23 Sep 2021 14:53:29 -0700 (PDT) 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 :cc; bh=wusfx6UjSpOrhJrRtwS/Zsu+hzZdpPDJjjJUhoBrn3I=; b=kWIWERMa6viKI2LtgOxFpyeksLSni7+Kmx/zD4qAReYcS2fkMk/IrpG6W0bJP51Zf4 Au1naXFeifSdBkVHeT11NYQhyVKeXSKsWEbY+cWbWv62yohf7K+CTWur0UgS0UGVUBvE QLLzxBjLTxgmwB+WYEqaKloXKwuJnFB9dIXZYVXpxSXBfkMA7jjwWdwX7X10n6t/APr4 2VWsCnTqK41qmUp4mPGN86mdYLPZpaeLEr+Q7O5cHECRBFGTt5/hESHQepoJJQKmJkZR BYpKnMsFsUaGMwzLxjRhLQZ5E0/NdNs0w5BZWq85XgUy1e73LTWbncoW6jIQO5Qeuv+e QbJw== 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:cc; bh=wusfx6UjSpOrhJrRtwS/Zsu+hzZdpPDJjjJUhoBrn3I=; b=lWvNF2gLxUldi6n4iFUgjPnUnhA4AgoeEfy9C3DT9Zi1Ey34Ygb6La/QrQd9yZcXN1 Kd084Gy4rIIUVyUkf/EPK9DPCRBPggrnrXru22J8/JDsZyt3ti/Afb3fQMUm3JV6e6rS RN/n5N62l8CgVB4x3LOB2dL9BorQy4kVb0xw+T6VSMsSY8Mp6hmiZ8cdZwltqnpJmvOg GE7Qtmjyw6U60XLGxtMx7iviuDZ4h8YXwCwi9QRfDouR8x7ljOjw3VSq6862fxG7wB/p DlgHvSPhiyDK/8eIHC5pIySYr+oxutzM3eIWU0yUR17UYKxRNEZdUJB3q557QkE3Boeh dmVw== X-Gm-Message-State: AOAM532Vgd0NpuKt0UfZjHmc5kRWG6Q6NwlwC/iiG9XrruhsSkn2Nfjq sqTPuMqLp6hvJUCu2EsUlrihNXHA8yibogxBmvE= X-Google-Smtp-Source: ABdhPJywNb9hWn/kzn67DPfWWXuwdhE9h8zGhlwgiHIpg9PSmBkvTFDc4O504TjVE08aSnu/fX3hb+/85vcSyy5wGMk= X-Received: by 2002:a05:6638:203:: with SMTP id e3mr6197064jaq.88.1632434008398; Thu, 23 Sep 2021 14:53:28 -0700 (PDT) In-Reply-To: <8dbf9ce5-f01c-94ae-40a2-0fae688f856b@gmail.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::d34; envelope-from=damien.mattei@gmail.com; helo=mail-io1-xd34.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.23 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:20885 Archived-At: --000000000000309c9305ccb0a9aa Content-Type: text/plain; charset="UTF-8" yes i'm using GNU Guile 3.0.7, https://www.gnu.org/software/guile/docs/master/guile.html/Syntax-Transformer-Helpers.html i have tested a lot , even define-once again and i choose to use to assignment operators and portable code because the non-portable function do not bring more, finally it was not a bad idea to ask for a new function because we can do it with the actual toolbox... Damien On Thu, Sep 23, 2021 at 10:48 PM Taylan Kammer wrote: > Responding to myself: > > On 23.09.2021 22:27, Taylan Kammer wrote: > > > I can't seem to find syntax-local-binding in Guile 2.2 or 3.0. Did you > > have to import some special module, or are you using another version? > > Worked when I imported (system syntax internal). > > > Either way, I suspect that the following will not work with your macro: > > > > (let () > > (let () > > (<$ x 1)) > > (display x) > > (newline)) > > Indeed it doesn't work, though for a different reason: > > While compiling expression: > Syntax error: > unknown file:43:8: body should end with an expression in form (let () > (<$ x 1)) > > That's because indeed the inner let expands into: > > (let () > (define x 1)) > > And there has to be at least one expression after the define. So I tried: > > (let () > (let () > (<$ x 1) > (newline)) > (display x) > (newline)) > > And as I expected, it says 'x' is unbound: > > ;;; :44:45: warning: possibly unbound variable `x' > <$ : global scope : x > > ice-9/boot-9.scm:1685:16: In procedure raise-exception: > Unbound variable: x > > The only way it will work is if you never use nested scopes, but that will > lead to very strange Scheme code, and there will probably be many cases > where you accidentally use a nested scope without immediately noticing it. > > Note also that definitions aren't allowed everywhere. Consider this: > > (let () > (if 'whatever > (<$ x 1) > (<$ x 2)) > (display x) > (newline)) > > It leads to: > > While compiling expression: > Syntax error: > unknown file:49:17: definition in expression context, where definitions > are not allowed, in form (define x 1) > > Because the arms of 'if' aren't allowed to be definitions. > > -- > Taylan > --000000000000309c9305ccb0a9aa Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Responding to m= yself:

On 23.09.2021 22:27, Taylan Kammer wrote:

> I can't seem to find syntax-local-binding in Guile 2.2 or 3.0.=C2= =A0 Did you
> have to import some special module, or are you using another version?<= br>
Worked when I imported (system syntax internal).

> Either way, I suspect that the following will not work with your macro= :
>
>=C2=A0 =C2=A0(let ()
>=C2=A0 =C2=A0 =C2=A0(let ()
>=C2=A0 =C2=A0 =C2=A0 =C2=A0(<$ x 1))
>=C2=A0 =C2=A0 =C2=A0(display x)
>=C2=A0 =C2=A0 =C2=A0(newline))

Indeed it doesn't work, though for a different reason:

=C2=A0 While compiling expression:
=C2=A0 Syntax error:
=C2=A0 unknown file:43:8: body should end with an expression in form (let (= ) (<$ x 1))

That's because indeed the inner let expands into:

=C2=A0 (let ()
=C2=A0 =C2=A0 (define x 1))

And there has to be at least one expression after the define.=C2=A0 So I tr= ied:

=C2=A0 (let ()
=C2=A0 =C2=A0 (let ()
=C2=A0 =C2=A0 =C2=A0 (<$ x 1)
=C2=A0 =C2=A0 =C2=A0 (newline))
=C2=A0 =C2=A0 (display x)
=C2=A0 =C2=A0 (newline))

And as I expected, it says 'x' is unbound:

=C2=A0 ;;; <stdin>:44:45: warning: possibly unbound variable `x'<= br> =C2=A0 <$ : global scope : x

=C2=A0 ice-9/boot-9.scm:1685:16: In procedure raise-exception:
=C2=A0 Unbound variable: x

The only way it will work is if you never use nested scopes, but that will<= br> lead to very strange Scheme code, and there will probably be many cases
where you accidentally use a nested scope without immediately noticing it.<= br>
Note also that definitions aren't allowed everywhere.=C2=A0 Consider th= is:

=C2=A0 (let ()
=C2=A0 =C2=A0 (if 'whatever
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (<$ x 1)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (<$ x 2))
=C2=A0 =C2=A0 (display x)
=C2=A0 =C2=A0 (newline))

It leads to:

=C2=A0 While compiling expression:
=C2=A0 Syntax error:
=C2=A0 unknown file:49:17: definition in expression context, where definiti= ons are not allowed, in form (define x 1)

Because the arms of 'if' aren't allowed to be definitions.

--
Taylan
--000000000000309c9305ccb0a9aa--