unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Taylan Kammer <taylan.kammer@gmail.com>
To: Damien Mattei <damien.mattei@gmail.com>,
	William ML Leslie <william.leslie.ttg@gmail.com>
Cc: Jean-Paul Roy <jean-paul.roy@unice.fr>,
	guile-devel <guile-devel@gnu.org>
Subject: Re: new function
Date: Wed, 22 Sep 2021 20:51:45 +0200	[thread overview]
Message-ID: <d8f8694a-6de0-f6f6-5c8a-7f9f110a95de@gmail.com> (raw)
In-Reply-To: <CADEOadeqRmNxq3zNt2Lbj5f3Fk6_gnUq_wtey7pBg9NC3cMcYA@mail.gmail.com>

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.

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



  reply	other threads:[~2021-09-22 18:51 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-19  7:54 new function Damien Mattei
2021-09-19 14:41 ` Matt Wette
2021-09-19 14:43   ` Matt Wette
2021-09-19 21:38 ` Taylan Kammer
2021-09-21 12:26   ` Damien Mattei
2021-09-22  8:44   ` Damien Mattei
2021-09-22  9:06     ` William ML Leslie
2021-09-22  9:53       ` Damien Mattei
2021-09-22 18:51         ` Taylan Kammer [this message]
2021-09-22 21:52           ` William ML Leslie
2021-09-23  8:40             ` Damien Mattei
2021-09-23 19:03             ` Taylan Kammer
2021-09-23 17:27           ` Damien Mattei
2021-09-23 18:00             ` Maxime Devos
2021-09-23 20:27             ` Taylan Kammer
2021-09-23 20:42               ` Damien Mattei
2021-09-23 20:48               ` Taylan Kammer
2021-09-23 21:53                 ` Damien Mattei
2021-09-24  4:41                   ` Damien Mattei

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d8f8694a-6de0-f6f6-5c8a-7f9f110a95de@gmail.com \
    --to=taylan.kammer@gmail.com \
    --cc=damien.mattei@gmail.com \
    --cc=guile-devel@gnu.org \
    --cc=jean-paul.roy@unice.fr \
    --cc=william.leslie.ttg@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).