I can see several problems here. One has to do with email and line-ends. You probably meant to send:
coclass 'myclass' empty =: '' classname =: myclass A_myclass_=: 1 :'a =. empty&u classname' This defines a class named 'myclass' but note that a=. in your definition of A is superfluous because =. is local assignment. You could remove the assignment or you could change =. to =: Note also that A_myclass_=: ... is equivalent to A=: ... because you are already in the myclass locale at that time. Note also that conew 'A' is probably not relevant since your class name is 'myclass'. Finally, note that '' conew 'myclass' or '' conew 'A' or something like that (with a left argument to conew) is what I would expect you would need to trigger the value error on create. That said, I was not able to reproduce your error message. Thanks, -- Raul On Tue, Dec 9, 2014 at 11:15 AM, Jon Hough <[email protected]> wrote: > > > > I was playing with your adverbs.Any idea why the following doesn't work? > coclass 'myclass'empty =: ''classname =: myclass > A_myclass_=: 1 :'a =. empty&u classname' > > > > conew A > > > error is: > > > I get the following error: > |value error: create__w > > > | create__w x > > > My intention was to instantiate 'a' as an instance of myclass (but also > keeping it private for whatever reason). > > > > > > > > >> Date: Tue, 9 Dec 2014 03:31:23 +0000 >> From: [email protected] >> To: [email protected] >> Subject: [Jprogramming] A neat OOP trick with adverbs >> >> adverbs can return nouns, though most are designed to return a verb. >> >> 1 : 'm + y' NB. a verb because it accesses y >> 1 : 'u 2' NB. returns a noun because it doesn't access y even though it >> uses a verb as adverb parameter >> >> Consider this noun producing adverb, >> A_z_ =: 1 : 'a =: u a' >> >> its defined in z, just for convenience. It applies its verb parameter to a >> and stores the result in a. The value of a it will use is whatever locale >> it is qualified with. >> >> a=.1 >> a_b_ =: 3 >> >> +: A >> 2 >> >> +: A_b_ >> 6 >> a_b_ >> 6 >> >> a&+ A_b_ NB. the a parameter is taken from caller's locale as u is parsed >> before it is passed to A_b_ >> 8 >> >> >> a_b_ =: i.5 >> a&(0}) A_b_ NB. sending parameters to amend in place >> 2 1 2 3 4 >> >> >> OOP approach often involves creating side effects in class instances. Noun >> returning adverbs can access all instance variables (or other program data), >> and make any side effects it wants. For instance, it can save or backup >> data to disk in the last amend example. >> >> The neat part is that with class defined adverbs, you can send verb messages >> to your objects. Even though they are verbs, they can be bound with many >> caller supplied nouns (such as the 2 parameters to }), and in a tacit >> expression caller variables get fixed into the supplied verb. Its also >> neat, because many other uses of adverbs in objects are unintuitively >> problematic in their parsing. >> ---------------------------------------------------------------------- >> 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
