From: Maxime Devos <maximedevos@telenet.be>
To: Stefan Israelsson Tampe <stefan.itampe@gmail.com>
Cc: guile-devel@gnu.org
Subject: Re: A lexical use-modules?
Date: Sun, 27 Mar 2022 17:11:38 +0200 [thread overview]
Message-ID: <77d4bd519cf2c8cb1e32c6ca31534c615c8ccb9e.camel@telenet.be> (raw)
In-Reply-To: <CAGua6m0H1CZOpDtCUgX=+h6P+zT74_VEA8etQKKs5JwVGLurGQ@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2114 bytes --]
[Re-added guile-devel# to CC]
Stefan Israelsson Tampe schreef op zo 27-03-2022 om 16:37 [+0200]:
> I mean that modul-ref is a hash-table lookup, and that's more
> expensive as you say. I suggested that lexical variables should be
> let bound
> because you can deduce more things with them e.g. in
>
> (let ((a (@ x y)))
> (when (vector? a) code ...))
>
> Then a is known to be a vector and the check can be avoided inside
> code ...
> You suggest to use (@ x y) everywhere which is not terrible,
> especially with wingo's recent work. But still not sure that all
> optimisations work for referencing (@ x y) all the time.
I could do this, but:
* this won't work for macros, so I would have to make a special case
for them
* the imported variables might not yet have been initialised. E.g.:
(lambda ()
(use-modules/lexical (foobar))
a-foo ; initially #false
(initialise-foobar!)
a-foo) ; now 'footastic'
The problem with your proposal is that modifications to global
variables would not be detected --- the idea of 'use-modules' is to
import the _variables_, not their current _values_.
Additionally, doing the latter would be backwards-incompatible.
* not all imported variables might be used, so your proposal might
make things worse. E.g.:
(define (foo)
(use-modules (ice-9 exceptions))
(if (do-stuff)
'ok
(raise (make-some-exception with variables from (ice-9
exceptions)))))
In the normal case, the variables would not need to be dereferenced.
* I just want to make lexical use-modules work and I'm not currently
interested in (possibly futily) trying to squeezing out some extra
% or ‰ of performance.
> Would be nice though to be able to select the vars to be bound and
> improve on compilation speed if there is a lot of baggage (large
> module and only few var used)
When making a patch for merging 'use-module/lexical' into 'use-
modules', I intend to preserve support for #:select.
Greetings,
Maxime.
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 260 bytes --]
next prev parent reply other threads:[~2022-03-27 15:11 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-26 19:21 A lexical use-modules? Maxime Devos
[not found] ` <CAGua6m33_=0=B9jaL4Jw7yP=yycD0eFxiAMK62iVBPuUV8F2wg@mail.gmail.com>
[not found] ` <4fb1eef748667d5e33d9df674af77ff52d30cd00.camel@telenet.be>
[not found] ` <CAGua6m1eNt5ABwDGT_3ifwCjT5YQkpd8W5XBjgwYGZE2B8WW0g@mail.gmail.com>
2022-03-27 10:40 ` Maxime Devos
[not found] ` <CAGua6m0H1CZOpDtCUgX=+h6P+zT74_VEA8etQKKs5JwVGLurGQ@mail.gmail.com>
2022-03-27 15:11 ` Maxime Devos [this message]
2022-03-29 13:20 ` Ludovic Courtès
2022-03-29 14:59 ` Maxime Devos
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=77d4bd519cf2c8cb1e32c6ca31534c615c8ccb9e.camel@telenet.be \
--to=maximedevos@telenet.be \
--cc=guile-devel@gnu.org \
--cc=stefan.itampe@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).