Hello,
To add and remove verbs dynamically to a class from an instance, I wrote the
following:
addv =: (0!:0) inlocale
remv =: (erase@<) inlocale
I designed inlocale based on the JfC code for InLocales Conjunction [1]
inlocale =: 2 : 0
l =. gcurrent ''
class =. {. @ copath n
cocurrent class
u y
cocurrent l
''
)
This works in my tests.
cocurrent 'base'
1. test01 =: 3 : 0
2. c =. conew 'myclass' NB. use copathnl__c '' to inspect
3. try. hello__c ''
4. catch.
5. vs =. 'hello =: 3 : 0',CRLF,'smoutput ''hello''',CRLF,')'
6. c addv vs
7. hello__c ''
8. end.
9. smoutput copathnl__c ''
10. c remv 'hello'
11. smoutput copathnl__c ''
12. destroy__c ''
13. )
However, I do not understand two points:
1) When to design inlocale as an adverb (1 : 0) and when as a conjunction(2
: 0)?
2) How does inlocale get the 'n' it wants in the execution of the statement
number 6 & 10 in the test code?
If this is already written down somewhere, please do point me to the
reference.
Thanks,
Yuva
[1]
http://www.jsoftware.com/help/jforc/writing_your_own_modifiers.htm#_Toc191734500
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm