* use-modules: selecting, which symbols not to load @ 2012-12-27 3:43 Panicz Maciej Godek 2012-12-27 8:31 ` Thien-Thi Nguyen ` (2 more replies) 0 siblings, 3 replies; 8+ messages in thread From: Panicz Maciej Godek @ 2012-12-27 3:43 UTC (permalink / raw) To: guile-user Hey, I've been thinking about the ways `use-modules` can be used. Namely, one can import selected symbols from a module, and additionally can rename specified symbols. What I've been lacking is specifying symbols that are NOT meant to be imported from a module. So I'd wish to be able to load modules in the following manner: (use-modules ((rnrs) #:version (6) #:without (write display))) I think it can sometimes be desirable to import the whole public interface except certain bindings. Of course, similar effect could be worked around by writing a smart renamer, such as (use-modules ((rnrs) #:version (6) #:renamer (lambda(name) (if (or (equal? name 'write) (equal? name 'display)) (symbol-append 'unused: name) name))) but it's much more complicated, and it creates some unnecessary garbage. If I really wanted to exclude those two symbols, I'd need to import all the remaining symbols from the module, which would be bothersome and require me to change my header as the module changes. Or maybe there is an easy way to exclude certain symbols from import-list? Best regards! ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: use-modules: selecting, which symbols not to load 2012-12-27 3:43 use-modules: selecting, which symbols not to load Panicz Maciej Godek @ 2012-12-27 8:31 ` Thien-Thi Nguyen 2012-12-28 0:05 ` Panicz Maciej Godek 2012-12-28 4:34 ` Mark H Weaver 2013-01-06 10:56 ` Ian Price 2 siblings, 1 reply; 8+ messages in thread From: Thien-Thi Nguyen @ 2012-12-27 8:31 UTC (permalink / raw) To: Panicz Maciej Godek; +Cc: guile-user [-- Attachment #1: Type: text/plain, Size: 1159 bytes --] () Panicz Maciej Godek <godek.maciek@gmail.com> () Thu, 27 Dec 2012 04:43:16 +0100 I think it can sometimes be desirable to import the whole public interface except certain bindings. Could you give a non-contrived example? I can't think of any, myself. I remember toying w/ the idea when adding ‘#:renamer’, w/ same doubts. [...] and require me to change my header as the module changes. Note that maintaining a blacklist and maintaining a whitelist is still maintenance. Better to ‘#:select’ exactly what you need and no more, i.e., take a purely constructive stance. That's maintenance, too, but the eye work is locally concentrated, which builds Quality, rather than broadly dispersed, which destroys (or, at best, delays) trust. (IMHO.) -- Thien-Thi Nguyen ..................................... GPG key: 4C807502 . NB: ttn at glug dot org is not me . . (and has not been since 2007 or so) . . ACCEPT NO SUBSTITUTES . ........... please send technical questions to mailing lists ........... [-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --] ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: use-modules: selecting, which symbols not to load 2012-12-27 8:31 ` Thien-Thi Nguyen @ 2012-12-28 0:05 ` Panicz Maciej Godek 0 siblings, 0 replies; 8+ messages in thread From: Panicz Maciej Godek @ 2012-12-28 0:05 UTC (permalink / raw) To: Thien-Thi Nguyen; +Cc: guile-user 2012/12/27 Thien-Thi Nguyen <ttn@gnuvola.org>: > () Panicz Maciej Godek <godek.maciek@gmail.com> > () Thu, 27 Dec 2012 04:43:16 +0100 > > I think it can sometimes be desirable to import the whole public > interface except certain bindings. > > Could you give a non-contrived example? I can't think of any, myself. > I remember toying w/ the idea when adding ‘#:renamer’, w/ same doubts. I recently had two similar cases, related with similar problem -- namely, with goops' generics. I wanted to use some features (I guess those were bytevector features) from (rnrs) module, but I also imported `write` and `display` procedures, which overrode the `write` and `display` generics from goops. I knew that I wasn't using write nor display from (rnrs) (because I didn't even realize their existence), but I didn't remember which features exactly did I use. Yesterday I had a similar case, because I was trying to make generics from slot-ref and slot-set! so that I could be able to extend their functionality, because I'm trying to extend the goops system to better suit my needs -- so I'd wish, for instance, to be able to record easily, which slots of an object have been modified -- and while I was trying to manage it using macros (and introducing a `define*-class` form with extended syntax), it occurred to me that using generics would be much simpler. > [...] and require me to change my header as the module changes. > > Note that maintaining a blacklist and maintaining a whitelist is still > maintenance. Better to ‘#:select’ exactly what you need and no more, > i.e., take a purely constructive stance. That's maintenance, too, but > the eye work is locally concentrated, which builds Quality, rather than > broadly dispersed, which destroys (or, at best, delays) trust. (IMHO.) I have to say that I completely don't understand this point. I'd never think, that 'precision' is the word that would apply to a module system. For me, the module system should be convenient, rather than 'concentrated'. It's like if -- in a conversation -- you'd need to specify which words you are going to use in which meaning beforehand, before you even say anything meaningful. Such symbols, as +, -, /, *, are available in scheme, even if you're not using any arithmetics in your program. Is it this 'broad dispersion' that you mentioned? I always get frustrated that I have to (use-modules (ice-9 match) (srfi srfi-2)), because I use the 'match' and 'and-let*' syntaxes as a part of the common logic of the language. OK, maybe arithmetics is an exception. But it's really a surprise that such procedures as inet-aton or select are available in the core guile, because I'd rather expect to (use-modules (unix socket)) or something like that, before using them. But I'm used to thinking of modules as if they were (more or less consistent) domains, so I would find it extremely irritating if I had to say explicitly, which notions from that domain I want to use. Thanks for your reply :) ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: use-modules: selecting, which symbols not to load 2012-12-27 3:43 use-modules: selecting, which symbols not to load Panicz Maciej Godek 2012-12-27 8:31 ` Thien-Thi Nguyen @ 2012-12-28 4:34 ` Mark H Weaver 2012-12-29 12:18 ` Panicz Maciej Godek 2012-12-30 21:08 ` Ludovic Courtès 2013-01-06 10:56 ` Ian Price 2 siblings, 2 replies; 8+ messages in thread From: Mark H Weaver @ 2012-12-28 4:34 UTC (permalink / raw) To: Panicz Maciej Godek; +Cc: guile-user Panicz Maciej Godek <godek.maciek@gmail.com> writes: > What I've been lacking is specifying symbols that are NOT meant > to be imported from a module. > So I'd wish to be able to load modules in the following manner: > > (use-modules ((rnrs) #:version (6) #:without (write display))) Although it is not documented, there's a way to do this: (use-modules ((rnrs) #:version (6) #:hide (write display))) Regards, Mark ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: use-modules: selecting, which symbols not to load 2012-12-28 4:34 ` Mark H Weaver @ 2012-12-29 12:18 ` Panicz Maciej Godek 2012-12-30 21:08 ` Ludovic Courtès 1 sibling, 0 replies; 8+ messages in thread From: Panicz Maciej Godek @ 2012-12-29 12:18 UTC (permalink / raw) To: Mark H Weaver; +Cc: guile-user >> to be imported from a module. >> So I'd wish to be able to load modules in the following manner: >> >> (use-modules ((rnrs) #:version (6) #:without (write display))) > > Although it is not documented, there's a way to do this: > > (use-modules ((rnrs) #:version (6) #:hide (write display))) Thanks a lot, that's just what I needed! ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: use-modules: selecting, which symbols not to load 2012-12-28 4:34 ` Mark H Weaver 2012-12-29 12:18 ` Panicz Maciej Godek @ 2012-12-30 21:08 ` Ludovic Courtès 2012-12-31 16:38 ` Mark H Weaver 1 sibling, 1 reply; 8+ messages in thread From: Ludovic Courtès @ 2012-12-30 21:08 UTC (permalink / raw) To: guile-user Hi! Mark H Weaver <mhw@netris.org> skribis: > Although it is not documented, there's a way to do this: > > (use-modules ((rnrs) #:version (6) #:hide (write display))) Woow, I didn’t know that one. Does someone want to document it? Thanks, Ludo’. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: use-modules: selecting, which symbols not to load 2012-12-30 21:08 ` Ludovic Courtès @ 2012-12-31 16:38 ` Mark H Weaver 0 siblings, 0 replies; 8+ messages in thread From: Mark H Weaver @ 2012-12-31 16:38 UTC (permalink / raw) To: Ludovic Courtès; +Cc: guile-user ludo@gnu.org (Ludovic Courtès) writes: > Mark H Weaver <mhw@netris.org> skribis: > >> Although it is not documented, there's a way to do this: >> >> (use-modules ((rnrs) #:version (6) #:hide (write display))) > > Woow, I didn’t know that one. Does someone want to document it? I'll work on it. Mark ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: use-modules: selecting, which symbols not to load 2012-12-27 3:43 use-modules: selecting, which symbols not to load Panicz Maciej Godek 2012-12-27 8:31 ` Thien-Thi Nguyen 2012-12-28 4:34 ` Mark H Weaver @ 2013-01-06 10:56 ` Ian Price 2 siblings, 0 replies; 8+ messages in thread From: Ian Price @ 2013-01-06 10:56 UTC (permalink / raw) To: Panicz Maciej Godek; +Cc: guile-user Panicz Maciej Godek <godek.maciek@gmail.com> writes: > What I've been lacking is specifying symbols that are NOT meant > to be imported from a module. > So I'd wish to be able to load modules in the following manner: > > (use-modules ((rnrs) #:version (6) #:without (write display))) While I see this is resolved now[0], but one option you could have considered was using the R6RS import form directly, which has an except clause. i.e. (import (except (rnrs) write display)) The import form is exported as part of the syntax case module, and so usable in any guile program. It may, however, be confusing to some people if you mix-and-match module forms. 0. I've been away from the mailing list, and so am only catching up today. -- Ian Price -- shift-reset.com "Programming is like pinball. The reward for doing it well is the opportunity to do it again" - from "The Wizardy Compiled" ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2013-01-06 10:56 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2012-12-27 3:43 use-modules: selecting, which symbols not to load Panicz Maciej Godek 2012-12-27 8:31 ` Thien-Thi Nguyen 2012-12-28 0:05 ` Panicz Maciej Godek 2012-12-28 4:34 ` Mark H Weaver 2012-12-29 12:18 ` Panicz Maciej Godek 2012-12-30 21:08 ` Ludovic Courtès 2012-12-31 16:38 ` Mark H Weaver 2013-01-06 10:56 ` Ian Price
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).