From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: William ML Leslie Newsgroups: gmane.lisp.guile.devel Subject: Re: new function Date: Thu, 23 Sep 2021 07:52:18 +1000 Message-ID: References: <147c2fb4-75d6-7cf6-4f4a-4edd996b0a4a@gmail.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000e4f6f105cc9c8715" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5950"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Damien Mattei , guile-devel To: Taylan Kammer Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Wed Sep 22 23:53:20 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 1mTAB5-0001Jf-Qn for guile-devel@m.gmane-mx.org; Wed, 22 Sep 2021 23:53:19 +0200 Original-Received: from localhost ([::1]:49766 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTAB3-0002At-H2 for guile-devel@m.gmane-mx.org; Wed, 22 Sep 2021 17:53:17 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:60392) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mTAAM-0002AK-Fr for guile-devel@gnu.org; Wed, 22 Sep 2021 17:52:34 -0400 Original-Received: from mail-io1-xd2e.google.com ([2607:f8b0:4864:20::d2e]:38852) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mTAAJ-0004TK-N1 for guile-devel@gnu.org; Wed, 22 Sep 2021 17:52:34 -0400 Original-Received: by mail-io1-xd2e.google.com with SMTP id e82so5304249iof.5 for ; Wed, 22 Sep 2021 14:52:31 -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=LAc4hoUVqHoXBFjbNGPwrrHoh5+W1hiGb504Cum57UQ=; b=lX6kZ9v06nqH+HAhwrETJ3KJEP79CAK/03ED7IVc4jEOp7f7v39wg8Aw0lwhZguhAx I6U1oFdg5cj+g1vnINOdNai99NsclID8QkGSIAUSJP1l3D5h6DW43itp0GF9yIPRLfZe Ge30LebIGTLTuEMvfYugNIXUVPJW431kkKFJix2zxQ2IwfWKhge3ppZZT4xPnQMxFy4v CAxINKzGPDalEfu3xzT/UCU3pTwBhY4N+uN5k+UDTDNSVnVfsdlKf8MTVPBdWZu9cRVd v/8oBauwy6n4Ft0FUSZC1l1eTAdvgGQys2b/lzAqlKqo3w6rjBfI9XTErRF0fqQH4oIT WfNQ== 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=LAc4hoUVqHoXBFjbNGPwrrHoh5+W1hiGb504Cum57UQ=; b=2qb/FD/73XoqhPwdgBqAHTZOjk5ztdAYY9uyyheTdNP144FIZXwmmqe9H/Rd1/Dgmb 4Pp+gGErTmloVvl+baV+8DI/LHS1EjnfhIjzttVAE7zfs1emSM3qRvfUr0GpbM/10yzk JM2JrgNOW5mXQNVs5ZDXTI222P+/LxKx41pAUkeb42gcrUFEsyMs1dYX1JpErPwXZbQR pnH9Sf1FZAsHbpLxgweU2FbaVc9jZO3K4ZOnJ9V7sk9an/wsQoYMNHPeEKOxevYlVhWn USc7uFV2vYES8ooo/Hhj6fJCqhbWNnaprwgZgOuZwf5gkf1eJiIA8ALa/YeZTrdS/M8Z TL+Q== X-Gm-Message-State: AOAM532nbIvrRKYAxKB0THOJIFp0/mr6N+RO8RHROSeOJ3mo5HriEiHC hBLowpN2aQI/NnR7mIIu6iejCGDq/OpDjO969Vg= X-Google-Smtp-Source: ABdhPJz0tO576UPRFZMzsll9X69/rEPuHjIkqlFtVR55a5rWJ2hu3XRRl3lGDu8XnJgqj+ZeF+8gkn+d85ErnNHUk10= X-Received: by 2002:a6b:7104:: with SMTP id q4mr986597iog.29.1632347550446; Wed, 22 Sep 2021 14:52:30 -0700 (PDT) In-Reply-To: Received-SPF: pass client-ip=2607:f8b0:4864:20::d2e; envelope-from=william.leslie.ttg@gmail.com; helo=mail-io1-xd2e.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:20877 Archived-At: --000000000000e4f6f105cc9c8715 Content-Type: text/plain; charset="UTF-8" On Thu, 23 Sep 2021, 4:51 am Taylan Kammer, wrote: > On 22.09.2021 11:53, Damien Mattei wrote: > > i already do it this way for internal defines ,using a recursive macro > that build a list of variable using an accumulator. It can works but macro > expansion seems slow, it was not immediate at compilation on a little > example (oh nothing more that 2 seconds) but i'm not sure it is easily > maintainable, it is at the limit what macro can do i think ,for speed > reasons. In fact i can not really understand in Guile as it is based on C > and compiled when macro expansion happens,what is the time cost... so for > all those ,perhaps not objective reason ,i prefer to avoid. > > I don't think there's any other way to achieve what you want, especially > using portable Scheme code. The lexical scoping semantics of Scheme are > a very fundamental part of the language, and cannot be worked around in > portable Scheme code without using a macro that rewrites whole bodies of > lambda expressions. > > Even using implementation-specific hacks, you won't get very far. Any > compiled Scheme implementation, and even most interpreted ones, won't > allow you to modify an outer scope's set of variable definitions from > within an inner scope. > > So if you really want to have Python's scoping semantics in Scheme, you > will probably have to write a complex 'def' macro that walks through the > body and "hoists" variable definitions to the outermost scope. > Python is lexically scoped, and the assignment here is supposed to be local. > If you're targeting R6RS implementations, you can use syntax-case to > write such a macro, but it won't be easy. > > If you're targeting R5RS or R7RS-small implementations, you will have to > rely on syntax-rules, which will probably be extremely difficult for this > kind of complex macro. > > Personally I don't even know how I would approach the problem using the > more capable syntax-case, let alone pure syntax-rules. > > -- > Taylan > --000000000000e4f6f105cc9c8715 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Thu, 23 Sep 2021, 4:51 am Taylan Kammer, <taylan.kammer@gmail.com> wrote:
On 22.09.2021 11:53, Damien Mattei wrote:<= br> > i already do it this way for internal defines ,using a recursive macro= that build a list of variable using an accumulator. It can works but macro= expansion seems slow, it was not immediate at compilation on a little exam= ple (oh nothing more that 2 seconds) but i'm not sure it is easily main= tainable, it is at the limit what macro can do i think ,for speed reasons. = In fact i can not really understand in Guile as it is based on C and compil= ed when macro expansion happens,what is the time cost... so for all those ,= perhaps not objective reason ,i prefer to avoid.

I don't think there's any other way to achieve what you want, espec= ially
using portable Scheme code.=C2=A0 The lexical scoping semantics of Scheme a= re
a very fundamental part of the language, and cannot be worked around in
portable Scheme code without using a macro that rewrites whole bodies of lambda expressions.

Even using implementation-specific hacks, you won't get very far.=C2=A0= Any
compiled Scheme implementation, and even most interpreted ones, won't allow you to modify an outer scope's set of variable definitions from within an inner scope.

So if you really want to have Python's scoping semantics in Scheme, you=
will probably have to write a complex 'def' macro that walks throug= h the
body and "hoists" variable definitions to the outermost scope.

Pyt= hon is lexically scoped, and the assignment here is supposed to be local.


If you're targeting R6RS implementations, you can use syntax-case to write such a macro, but it won't be easy.

If you're targeting R5RS or R7RS-small implementations, you will have t= o
rely on syntax-rules, which will probably be extremely difficult for this kind of complex macro.

Personally I don't even know how I would approach the problem using the=
more capable syntax-case, let alone pure syntax-rules.

--
Taylan
--000000000000e4f6f105cc9c8715--