Arc Forumnew | comments | leaders | submitlogin
How are the libs in lib/ intended to be loaded?
3 points by zck 31 days ago | 2 comments
There are 49 files in Anarki's lib/ folder. 18 of them are loaded by libs.arc, which is loaded in boot.scm.

But that means there are 31 extra lib files that aren't loaded by default. How are they expected to get loaded?

Anarki doesn't seem to `cd` to its own directory, so I can't just call `(load "lib/files.arc")`. How do I load these extra libraries?

2 points by rocketnia 9 hours ago | link

I've always been frustrated with Arc's lack of a standard practice for loading dependencies (although I suppose akkartik might consider that a feature ^_^ ).

If the way Arc's lib/ directory has been used is any indication, the way to do it is:

- Start in the Arc directory when you run Arc, and never cd out of it.

- (load "lib/foo.arc"), or (require "lib/foo.arc") if you want to avoid running the same file multiple times

But I think for some Anarki users, the preferred technique has been somewhat different:

- Invoke Anarki from any directory.

- Ignore lib/ as much as possible. On occasion, load a library from there by using (load "path/to/arc/lib/foo.arc"), but a few libraries may make this difficult (e.g. if they need to load other libraries).

When I started writing Arc libraries, the first thing I wrote was a framework for keeping track of the location to load things relative to, so that my other libraries could load each other using relative paths regardless of which of the above techniques was in use. But the Lathe module system didn't catch on with anyone else. XD

More recently, eight years ago, rntz implemented the current-load-file* global variable that may make it easier for Anarki-specific libraries to compute the paths of the libraries they want to load. Nothing is currently using it in Anarki however.


1 point by akkartik 8 hours ago | link

Whoa, I could have sworn I responded to this one :/

rocketnia is right that I tend to just run Arc from within its directory, keeping it alongside any Arc program I may be working on at the moment. As a result, I'd kinda always assumed you could run it from anywhere and find yourself in the Arc directory once you loaded up. Now I find this isn't the case:

  $ pwd
  $ ./anarki/
  arc> ($:current-directory)
This was initially surprising, but of course we're only parameterizing the current directory while loading libraries:

I'm not sure what to do about this. In addition to rocketnia's `current-load-file*` suggestion, should we just expose `arc-path` from boot.scm? I couldn't immediately see how to get to it from Arc.