Ken had in mind, and Roger agreed, that the type of an array is the type of its atoms.  This leaves the question, Suppose there aren't any atoms?  They felt that such an array doesn't really have a type, but since you have to assign one, it might as well be numeric.

I have never agreed with this but I am not going to suggest overruling such authority.

They had to make exceptions for {. }. to avoid breaking some often-used patterns, but it seems they drew the line at $ .

You can see vestiges of empty-is-numeric in the Dictionary:

* the order of grade (/: y) refers to a type as numeric or empty

* (> y) explicitly does not open an empty array no matter what the type

* L. L: S: treat empty arrays as having boxing level 0, regardless of type

If a groundswell of user protest suggested that we change the error message for $, we could consider it.  The other cases would break too much, I expect.

Henry Rich

On 2/20/2023 9:27 AM, Jan-Pieter Jacobs wrote:
Looking through the implementation of dev/eformat, I found this line which
puzzled me:
https://github.com/jsoftware/dev_eformat/blob/4c285152bb27c2bfcb474738ea3b839e4ce96d0d/eformat.ijs#L496

There's nothing wrong with that line, or with the fact it triggers an
error, but it does indicate that $ raises an error in a situation where {.
does not, i.e. reshaping an empty array errors, while overtaking from one
does not.

Indeed, 5 $ '' or 5$ 0$0 give an error, while 5 {. '' and 5 {. 0$0 just
work, producing arrays of 5 spaces or zeros as expected. 5 $!.'' '' also
works, as does 5$!.1 ''.
Why wouldn't $ be able to see the data type (and thereby, fill element) of
it's y argument, and fill accordingly? As far as I remember, any noun in J
has a datatype, and a fill element. As the the fill element is a scalar,
the dimensionality being different in the case of $ shouldn't matter either.

Is there anything I'm missing, or is this really an inconsistency without
any reason for existence?

Best regards,
Jan-Pieter
----------------------------------------------------------------------
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