Paul Kienzle wrote:
On May 27, 2007, at 11:49 AM, Tom Holroyd (NIH/NIMH) [E] wrote:
Hmm... that still leaves the send/recv function in parallel which
will conflict with the posix socket interface.
Is there no way to implement namespaces?
Something like this needs to be done sometime.
pkg load socket
send(blah)
pkg load socket as skt
skt.send(blah)
We could get this sort of functionality with a new octave type
'module'.
Why not just use struct()? Let's say I'm defining a package called moo
in /tmp/moo:
---8<---
function b = f(a)
b = a + 2;
end
function b = g(a)
b = a + 3;
end
# emulate package being loaded as
# pkg load moo as moo
moo = struct("f", @f, "g", @g);
clear f
clear g
---8<---
Then I can do:
octave:1> source('/tmp/moo')
octave:2> moo.f(4)
ans = 6
octave:3> moo.g(4)
ans = 7
octave:4> f
error: `f' undefined near line 4 column 1
where I am using the "source" command above as a replacement for "pkg
load moo as moo".