locs_z_ =: 1 : 'm loc 18!:5 '''''
loc_z_=: (,&'_'@[ ,&'_'@, ":@>@])"1 0

   'Do' loc 'z' 
Do_z_ 

   'Do' locs 
Do_base_ 

   mean_asd_ =: +/%#
   data_asd_ =: 1 2 3

   ". ('mean' loc <'asd') , ' ' , ": data_asd_ 
2 

inl_z_ =: (cocurrent@] ".@] [)"1 0

   'mean data' inl <'asd' 
2

If you are running a string (".) inside a locale, all variable names must be 
localized.  The inl verb lets you run code in another locale reference.

For your purposes, you probably want to have the caller use locs to fix its 
variable locales as it builds the string to send to create.


----- Original Message -----
From: Jon Hough <[email protected]>
To: "[email protected]" <[email protected]>
Cc: 
Sent: Monday, September 15, 2014 10:38 AM
Subject: [Jprogramming] OOJ and calling a verb from another locale

OOJ = object oriented J
I have a preexisting verb, for example lets call it myVerb =. +/ % #. 
Next I define a class:
coclass 'MyClass'
create =: verb define       myValue =: ". y
)
So, essentialy my value is going to run the command y, using verb ".
So perhaps I want y to by 'myVerb 1 2 3'
Then, hopefully myValue will be 2.
So I do
myObj =: conew 'MyClass'
create__myObj 'MyVerb 1 2 3'
However, I get a value error for MyVerb. I asusme this is because myVerb was 
defined in a different locale.
I then tried create__myObj 'MyVerb_z_ 1 2 3'
Which also gives a value error.
By the way, what I am trying to do is pass a callback to the constructor of 
MyClass, so I can execute an arbitrary function. I am using ". to call the 
arbitrary function. I think this method of callbacks was shown in J for C.
So the question is, what is my code doing wrong?
Thanks.

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

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

Reply via email to