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