> > how do you keep track of dependencies between different files?
> >
> > Currently I do something like
> >
> > if utilities__loaded # true then load("utilities.max");
>
> Assuming each file sets a version number, maybe you could do something
> like
>
> if not(get('nset,'version)) then load("nset")
Thanks for the suggestions I got! Autoloads did not seem to solve my
problem, but I have now adapted the above and come up with the
following two macros:
,----
| /*
|
| dependency tracking: provide and require. Both should return the
| version, so you can, e.g., check require(feature) > 1.05 .
|
| */
|
| provide(what,[ver]) ::=
| buildq([what, ver],
| put('what,
| catch(block([inpart:true],
| map(throw, ver), true)),
| 'version)) $
|
| require(what, [path]) ::=
| buildq([what,
| path: catch(block([inpart:true],
| map(throw, path),
| ?intern(sconcat("&", what, ".max"))))],
| block(
| if get('what, 'version) = false
| then
| block(
| load(path),
| assert(
| not (get('what, 'version) = false),
| concat("Loaded \"", path, "\", but \"", 'what,
| "\" was not provided."))),
| get('what, 'version))) $
`----
This seems to work well, but I have two questions:
- are there any obvious problems with this implementation that I
failed to notice?
- require uses the symbol name as the default file name (appending
".max"). Is there no more generic way of doing this than
?intern(sconcat("&", quoted-symbol, ".max"))?
Currently I have those definitions in my maxima-init.mac; I think it
would make sense to have something similar available in Maxima by
default.
Thanks again to Barton Willis and Richard Fateman for their answers to
my original question. -
Albert.