Thanks! Yes, with this, I can reduce the test01 code to:
test01 =: 3 : 0 c =. conew 'myclass' NB. use copathnl__c '' to inspect try. hello__c '' catch. vs =. 'hello =: 3 : 0',CRLF,'smoutput ''hello''',CRLF,')' scr__c vs NB. c addv vs hello__c '' end. smoutput copathnl__c '' erase__c <'hello' NB. c remv 'hello' smoutput copathnl__c '' destroy__c '' ) with scr =: 0!:0 in the locale 'myclass'. This gives a better solution to my requirement. However, I do not understand how the inlocale conjunction that I have written works - how does it get the 'x' argument as the 'n' to extract the class information? On Mon, May 18, 2009 at 2:35 PM, Oleg Kobchenko <[email protected]> wrote: > > I don't see the point of these complications: "inlocale". > The mechanism is already in __numloc and _txtloc_ syntax. > > scripts_z_=: 0!:0 NB. named and implicitly inherited from "z" > > scripts_qq_ 'zz=: 3 : '' y+2 '' ' > zz_qq_ 3 > 5 > q1=: conew'qq' > scripts__q1 'zz3=: 3 : '' y+3 '' ' > zz__q1 3 > 5 > zz3__q1 3 > 6 > > zz4__q1=: 3 : ' y+4 ' NB. better: natural name definition > zz4__q1 3 > 7 > > erase__q1 <'zz4' NB. already defined > 1 > zz4__q1 3 > |value error: zz4__q1 > | zz4__q1 3 > > > > > ----- Original Message ---- > > From: Yuvaraj Athur Raghuvir <[email protected]> > > To: Programming forum <[email protected]> > > Sent: Monday, May 18, 2009 1:49:51 PM > > Subject: [Jprogramming] Understanding Conjunctions & Adverbs > > > > 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 > > > > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
