Menu

#19 loadproc() function?

open
nobody
None
5
2003-04-03
2003-04-03
No

Hmmm, there's:

loadfunc(...) for loading a C wrapper function, and
load(...) for loading an entire Unicon program, but

there's no way to dynamically load a Unicon procedure
(from the IPL, for example). Instead, one has to have
statically referenced the proper file in a link directive.

How about a:

loadProc(fname,pname)

that searches I/LPATH (whichever is the right one!)
for file fname.u and returns the procedure referenced
by pname from that file. So, for example:

int2bit := loadProc("bitint","int2bit")

would work. (I assume loadProc() would have to
link in *all* of bitint.u [since pname could reference
who knows what], so subsequent calls for other
procedures defined in bitint.u would be faster.

There are several other variants that would be
equally useful (any one of them would be sufficient).
For example, could have:

(a) linkFile(fname)

dynamic equivalent of "link fname" directive;
globals in
fname.u are made available as globals. (Have to
define
behavior if that global already exists, though...)

(b) namespace := linkFile(fname)

similar to (a), but returns a table of the globals in
fname.u, thus avoiding the namespace collision
problem. Also easier to dynamically 'unlink'...

I have a feeling that linkPackage(pName) would be
siimilarly useful.

Discussion


Log in to post a comment.