Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions q/dep/dep.q
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,17 @@ if[()~key `.finos.dep.resolvers; .finos.dep.resolvers:(`$())!()];
.finos.dep.priv.unload each exec moduleName from .finos.dep.list;
};

.finos.dep.useModule:{[name]
while[(ns:`$8?.Q.A,.Q.a)in key`.finos];
nsfull:.Q.dd[`.finos;ns];
nsfull set orig:(``z`q`Q`finos#get`);
({.finos.dep.loadModule x};name) . nsfull;
updated:get nsfull;
![`.finos;();0b;enlist ns];
newns:(key[updated]except key orig)#updated;
.finos.dep:updated[`finos;`dep];
newns};

.z.exit:{[handler;x]
.finos.dep.priv.unloadAll[];
handler[x]}$[()~key `.z.exit; (::); .z.exit];
20 changes: 20 additions & 0 deletions q/finos.q
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//system"l ",1_string .Q.rp`:.:finos_init.q;
system"l ",1_string .Q.rp`:::../finos_init.q;

provide:{[x;a]
if[not (sm:string[x]) in key .finos.dep.list;'"module not registered: ",.Q.s1 x];
n:` sv .z.M,`m,x;
path:.finos.dep.list[sm;`scriptPath];
l:.Q.m.p1 ll:.Q.m.pl[enlist path;enlist x];
if[0=count l;
-2 each enlist["tried the following paths:"]," ",/:ll;
'"notfound: ",string x];
if[not null m:.Q.m.M[(p:.Q.m.dl l;`)]`m;
$[m~`:;'`cycle;:m]];
r:.Q.m.ch[n;p;`;.Q.m.ld l;a];
:[r;(0b;r);
[.Q.m.M[(p;`)]:enlist[`m]!enlist n;n];
(1b;r);
'r]}

export:([provide])