Thanks. In the example below, in line 6, c addv vs NB. addv =: (0!:0) inlocale the left and right arguments to addv are nouns where c is the instance of a class, and vs is a string.
Now, inlocale conjunction below gets the x passed to addv to extract the class of the instance c. >From your description, I would have expected that inlocale would attempt to work on noun vs (string). What am I missing? On Mon, May 18, 2009 at 1:35 PM, Henry Rich <[email protected]> wrote: > conjunctions take 2 operands, adverbs only one. If you need to pass in > two pieces of data, you can either box them as the left operand of an > adverb or pass them in as the two operands of a conjunction. It's > similar to the difference between monadic and dyadic verbs. > > In a conjunction, the interpreter sets n to the value of the right > operand before the modifier starts running, but only if the right > operand is a noun. This gives you a way to have the modifier fail if it > needs a noun and is given something else. > > Henry Rich > > Yuvaraj Athur Raghuvir wrote: > > 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
