I wrote:
> I'm suggesting something along the lines of:
> kid =: beget ''
>
> where beget is a conew, and calls something along the lines of:
> require 'task'
> fork BINPATH_z_, PATHSEP_j_ (, }.~ [ i:~ ,) >{.ARGV_z_
I forgot to say there would/should be another function that completely clones
the running process (as far as possible, anyway):
doppelganger =: clone ''
This wouldn't be hard to do, and would make it possible to easily farm out
work; for example, we could replace:
someDeeplyNestedVerb =: verb define
...
...
Result =: someOtherVerb y +/ i. 10
)
with
someDeeplyNestedVerb =: verb define
...
...
dg =: clone ''
callback__dg =: 3 : 'Result =: y'
someOtherVerb__dg y +/ i. 10
)
Of course, the further down this road we go, the closer we come to a threading
model, with all the headaches and micromanagement
that entails. And one major reason to use J is specifically to avoid those
headaches.
But J has the advantage of allowing us to unambiguously detect when a
computation is functional (stateless [1]), and functional code
is much easier to parallelize. In these cases, we could even define convenient
modifiers:
someDeeplyNestedVerb =: verb define
...
...
someStatelessVerb delegate 3 : 'Result =: y' y +/ i. 10
NB. Could even have the delegate share-back its
NB. result via mapped files, avoiding the need for
NB. the assignment in the callback
)
These cover functions would manage the object lifecycle, and allow programmers
to focus on logic, rather than the details of
interoperation. As time progresses, we could add more functionality (e.g.
maintaining a pool of sub-Js to do functional [stateless]
computations on our behalf).
-Dan
[1] But unfortunately not side-effect free, though we could write utilities to
help detect those situations (which we could also
leverage to build a secure sandbox).
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm