This is a good explanation. Another way of phrasing this might be as a negative: what would be an advantage of heterogeneous arrays over boxed arrays?
Heterogenous arrays would seem to increase complexity in a way that is not necessarily helpful by forcing us to work with interactions between different types. For example, it's plain what to do in each of the following cases for homogeneous arrays: 2=/\ 1 1 1 2 2 3 4 5 5 7 1 1 0 1 0 0 0 1 0 2=/\'aaabbcdeef' 1 1 0 1 0 0 0 1 0 but what would happen if I could use a hetero vector in this expression, i.e . 2=/\'aaa' 2 2 3 'xyz' ? We'd have to define substantially more edge conditions between data types. Note, too, that J already subsumes quite a number of (internally) different data types into only two broad classes: numeric and character. Boxing is orthogonal to these basic distinctions - if we come up with another fundamental data type, it would still fit into the scheme of boxing. On 5/27/07, Sherlock, Ric <[EMAIL PROTECTED]> wrote:
I'm sure others add to my perhaps simplistic (hopefully not inaccurate) explanation, but in essence it is because a homogeneous array of type "boxed" can contain atoms of different types, which accomplishes the same thing. ]array=:3 5$'Text';3.45;2882;'Not numeric';2r3;0;1 +-----------+----+----+-----------+----+ |Text |3.45|2882|Not numeric|2r3 | +-----------+----+----+-----------+----+ |0 |1 |Text|3.45 |2882| +-----------+----+----+-----------+----+ |Not numeric|2r3 |0 |1 |Text| +-----------+----+----+-----------+----+ 3!:0 array NB. Type of array 32 3!:0 each array NB. Type of elements in array +-+---+-+-+---+ |2|8 |4|2|128| +-+---+-+-+---+ |1|1 |2|8|4 | +-+---+-+-+---+ |2|128|1|1|2 | +-+---+-+-+---+ >From http://www.jsoftware.com/help/dictionary/dx003.htm Type. The internal type of the noun y , encoded as follows: 1 boolean 2 literal 4 integer 8 floating point 16 complex 32 boxed 64 extended integer 128 rational 1024 sparse boolean 2048 sparse literal 4096 sparse integer 8192 sparse floating point 16384 sparse complex 32768 sparse boxed 65536 symbol 131072 unicode > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Fuchs Ira > Sent: Monday, 28 May 2007 14:44 > To: [email protected] > Subject: [Jprogramming] J and heterogeneous arrays > > I was reading the J for APL Programmers paper and I was > wondering if someone could explain the rationale underlying > the decision to not include heterogeneous arrays in J. > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
-- Devon McCormick, CFA ^me^ at acm. org is my preferred e-mail ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
