Arc Forumnew | comments | leaders | submitlogin
1 point by bogomipz 6127 days ago | link | parent

When you do (use 'foo), is the module globally known as 'foo and in the current file accessible without prefix? This seems the most straight forward since the file is named "foo.arc" and you don't want to load it multiple times when used by different modules. But then I wonder what happens when you (useas 'foo 'fu), and why is this even useful if (use 'foo) makes sure you don't need to do foo@bar. Actually, why even have the foo@bar syntax at all?

Is each source file treated as a separate module?

How about this even simpler suggestion?

  (use foo)
Loads "foo.arc" into a symbol table named 'foo, unless this is already done, and makes all of its symbols available in the current module (the current source file, or a general module 'user or whatever if done in the repl).

  (use foo bar baz (barbeque bq))
Loads module 'foo, but only imports symbols 'bar, 'baz and 'bq locally, where the latter is originally named 'barbeque. In case you just want to rename one function to avoid a name clash, and want everything else imported straight up, this should be possible as well;

  (use foo (barbeque bq) *)


2 points by pau 6127 days ago | link

In Python, if you do

  import string
you still have to access symbols within string using the prefix, and I imagined Arc's (use ...) doing the same.

Arc should register in some way that the module was loaded, since if two other modules do (use 'x), then they have to reference the same table. This is, afaik, what Python does. So 'locally' (within the current module), you access the symbol table of another package with the name you want (if you don't supply one, then it's the same as in the file), but the system remembers who is who globally.

Each source file is a module, yes.

To be able to load a list of modules, like

  (map use '(string regex parser))
I think that it is important that the first parameter to the use function be a symbol, e.g. (use 'string) instead of (use string).

I like your suggestion (specially changing the names to avoid clashes)... Yes, it could be a nice way to avoid the prefix... ;)

-----