unofficial mirror of help-guix@gnu.org 
 help / color / mirror / Atom feed
From: Wojtek Kosior via <help-guix@gnu.org>
To: help-guix@gnu.org
Cc: jgart <jgart@dismail.de>
Subject: Re: When do you re-export?
Date: Wed, 12 Oct 2022 08:21:49 +0200	[thread overview]
Message-ID: <20221012082149.36f2993f@koszkonutek-tmp.pl.eu.org> (raw)
In-Reply-To: <20221011162848.GB19896@dismail.de>

[-- Attachment #1: Type: text/plain, Size: 2540 bytes --]

> Hi,
> 
> When should I re-export something in a module?
> 
> docs say [...]
>
> The docs don't explain why you would want to even do a re-export in the first place...
> 
> Could someone provide some examples as to why I would want to use this? It
> would be much appreciated!
> 
> --
> jgart

Hello,

Although I have very little scheme knowledge (disclaimer) I thought I
could perhaps help using some generic programming knowledge.

It seems re-exporting things is just helpful for maintaining the
desired code structure. If you're for example writing a library, you
might find it useful to split the code into several modules.

Typically, only a subset of the functions and structures you define are
meant to be exported as library's external API. Meanwhile, as a result
of various dependencies between them, the definitions you want to make
public might have landed in different code files and effectively in
different modules. Now, in order to make them available to library
users by the means of a single import, it is perfectly justifiable to
have them imported by and re-exported by a single module.

Guix itself seems to be doing something like that[1].

And making a "re-export all public definitions" wrapper is just an
example. There may be other reasons we might want to have 'foo'
importable from module 'bar' despite it being originally defined in
some other module (e.g. 'baz') ☺

Best,
Wojtek

[1] https://git.savannah.gnu.org/cgit/guix.git/tree/guix.scm#n23


-- (sig_start)
website: https://koszko.org/koszko.html
PGP: https://koszko.org/key.gpg
fingerprint: E972 7060 E3C5 637C 8A4F  4B42 4BC5 221C 5A79 FD1A

Meet Kraków saints!           #37: blessed Michał Tomaszek
Poznaj świętych krakowskich!  #37: błogosławiony Michał Tomaszek
https://pl.wikipedia.org/wiki/Michał_Tomaszek
-- (sig_end)


On Tue, 11 Oct 2022 16:28:48 -0500
jgart <jgart@dismail.de> wrote:

> Hi,
> 
> When should I re-export something in a module?
> 
> docs say the following:
> 
> Add all variables (which must be symbols or pairs of symbols) to the
> list of re-exported bindings of the current module. Pairs of symbols
> are handled as in export. Re-exported bindings must be imported by the
> current module from some other module.
> 
> The docs don't explain why you would want to even do a re-export in the first place...
> 
> Could someone provide some examples as to why I would want to use this? It
> would be much appreciated!
> 
> --
> jgart
> 



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

  reply	other threads:[~2022-10-12  6:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-11 21:28 When do you re-export? jgart
2022-10-12  6:21 ` Wojtek Kosior via [this message]
2022-10-22 14:15 ` Maxim Cournoyer

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://guix.gnu.org/

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

  git send-email \
    --in-reply-to=20221012082149.36f2993f@koszkonutek-tmp.pl.eu.org \
    --to=help-guix@gnu.org \
    --cc=jgart@dismail.de \
    --cc=koszko@koszko.org \
    /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).