guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: module naming


From: Rob Browning
Subject: Re: module naming
Date: 24 Apr 2001 00:28:10 -0500
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7

(If this topic has already been beaten to death in the past, and I'm
 just re-starting one of those inevitable cyclical arguments, then
 please let me know and I'll shut up :>)

thi <address@hidden> writes:

So what does "@" do?

I tend to agree that being able to have a little more control over the
module import/export process might be a good idea.  I can see where
being able to import selected symbols, rather than all of them, could
be useful.

However, I wonder if, going under the principle of "least necessary",
we could modify use-modules to accept an argument like
:no-default-imports so you could say:

  (use-modules (foo bar) :no-default-imports)

and then have a parallel operation to "export" like this:

  (import-from module module . items)

where each item in items is (as you specified in your functions)
either a name or a old/new name list i.e.:

  (import-from (foo bar)
   x y z)

or

  (import-from (foo bar)
   (x new-x) (y new-y) z)

Then using import-from people could construct whatever other, more
sophisticated operations they need, re-exporting, renaming, etc.

Note that we could do without the :no-default-imports option to
use-modules and just let people use import-from *instead of* ever
having a use-modules in these situations, but that brings up some
"interesting" and possibly confusing questions, about if/when code at
the top level of a module file should actually run (though I feel
fairly sure that's probably been discussed as a thorny issue on the
compilation front too).

One other thing I can see might also be helpful would be to have the
ability to use a module, but rename all its symbols in a programmatic
way on import, something like this:

  (use-modules (foo bar)
   :rename-symbols (lambda (sym)
                     (string->symbol
                      (string-append "foo:" (symbol->string sym)))))

But it feels like there ought to be a more elegant way to solve this
problem without a more complex interface.  Maybe something like the
following (given a public way to ask a module for its exports):

  (apply
   import-from
   (map
    (lambda (sym)
      (list sym
            (string->symbol (string-append "foo:" (symbol->string sym)))))
    (module-exports (foo bar))))

though of course, the scoping for this probably wouldn't be right and
apply doesn't work on macros :>

-- 
Rob Browning <address@hidden> PGP=E80E0D04F521A094 532B97F5D64E3930



reply via email to

[Prev in Thread] Current Thread [Next in Thread]