An array of object values that 'often' to be dealt with as an array is
perhaps best implemented as a normal J array that is a global class object.
This can be referenced directly as an array and then in each of the objects
the object value is the index into the class array and you use simple
accessor funtions.

On Mon, Apr 20, 2009 at 12:49 PM, Matthew Brand <[email protected]>wrote:

> If I have a simple class such as:
> coclass 'example'
>
> create =: 3 : ' X =: y'
> destroy =: codestroy
>
> And I make a list of new objects:
> n =.'example' (conew~)"(1 0) i.4
>
>   n
> +-+-+-+-+
> |4|5|6|7|
> +-+-+-+-+
>
> Then I can get at the X's inside each object like this:
>   X_4_
> 0
>   X_5_
> 1
>
> And like this:
> v =. <":5
> X__v
> 1
>
> But how can I reconstruct the values of the X's from the list n?
>
> i.e., is there anything that looks like this?
>    (X__ <something>)"0 n
> 0 1 2 3
>
> Presumably the code to call a method on each object would look the same?
>
> I.e if there was a method: getX =: 3 : 'X'
>
> then calling it would look like?
> (getx__ <something>)"0 n
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to