Because object references are part of J's morphology, not syntax , they are harder to manipulate at run time than other data. That is, references to objects are baked in names, and are not indicated as free parameters.
, , . - , - , , () .
3 apply&>~ 'increment_' ,L:0 objects ,&.> '_'
- , . :
3 dyad def 'increment__y x'"0 objects
, :
incrementObjs =: dyad define
increment__x y
)
objects incrementsObjs"0] 3
, JSoftware 6 , . (.. v6) - :
incrementObjs =: dyad define
o =. x. NB. x and y used to be spelled x. and y.
increment__o y NB. but increment__x. would raise an error
)
, incrementsObjs"0 objects for_o. objects do. ; , J- .
: J , , , Java #.
; J, . "", . J , J ( " ", GB: , , ℕ ).
:
coclass 'Object'
create =: 3 : 'state =: 0'
increment =: 3 : 'state =: state + y'
destroy =: codestroy
cocurrent 'base'
objects =: 'Object' conew 0 0 0
, objects =: 'Object' conew 0 0 0;
objects =: (0 conew 'Object') , (0 conew 'Object') , 0 conew 'Object'.
: 3 , 3 .
, , . "" , , , .
? :
3 dyad def 'increment__y x'"0 objects
:
increment__objects 3
J 1.
1 , , , J, 90- , . , .
J, ; , , , .