> 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 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 >