Stefan Scott Alexx wrote:
>  So I am curious whether J has mechanisms similar to K's dependencies and 
> triggers.

Nope.  We do have memory mapped files which update "everywhere" (including 
across processes) simultaneously, but you aren't
"notified" of this (the global just always has the "correct", current value) .

>  Alternatively, (if J lacks such mechanisms) I would be very appreciative for 
> any ideas 
>  on how to go about simulating K's dependencies and triggers in J.

This really depends on what triggers these changes.  If it's just code that 
assigns a global in K, then in J instead of the
assignment statement, you could call a function (verb) which updates the global 
and all its relatives.  This verb would be
semantically similar to the "dependency" statements you mentioned in K.

If it's some external event, like a user clicking a button or a request coming 
in on a socket, or a certain amount of time passing,
then J does support asynchronous callbacks for these events, and in that 
callback you could do the update as usual.

But in J we tend to think more in terms of functions (verbs) and compositions 
(conjunctions), so that for example you wouldn't have
a data (noun) relationship like this:

        AVERAGE_SIZE =: (+/ % #) SIZES    NB.  AVERAGE_SIZE and SIZES are nouns

you'd be much more likely to express the relationship in terms of verbs and 
conjunctions, like this [1]:

        avgSize =: (+/ % #)@:sizes                  NB.  avgSize and sizes are 
verbs

-Dan 


[1]  These two sentences can be "read" the same in English ("the average size 
is the average of the sizes"), but renders the value
of avgSize timeless, in a sense.  That is, since the value of (the verb) 
"sizes" is always correct, then so is the value of avgSize,
because that is just a simple functional (stateless, side-effect-free) verb on 
top of sizes.  

Sorry if that's unclear; it's a hard concept to express.  I once saw a 
presentation in an APL conference in Florida where a
presenter hit this on the head, but I've forgotten how he expressed it.

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to