It's a good thing. To do otherwise is a joke - an empty-array joke, in particular:
A man sits down in a diner and asks the waitress for a cup of coffee "without cream". The waitress replies: "We're out of cream, sir. Would you like it without milk?" On Tue, Oct 29, 2013 at 12:43 PM, Zsbán Ambrus <[email protected]> wrote: > On Sat, Oct 26, 2013 at 7:04 AM, Ganesh Rapolu <[email protected]> > wrote: > > The dictionary does not say that the two arguments for -: have to match > in > > type so this result is correct. Nevertheless, I would be glad if someone > > could provide an explanation/justification for this behavior. > > > > datatype m =. 0 {. 'adaf' > > literal > > datatype n =. 0 {. 10 0 10 10 > > integer > > m -: n > > 1 > > The J language generally tries to treat empty values the same > regardless of type. I thought this general design rule was documented > explicitly somewhere in the dictionary (or the primer?), but I can't > find it right now. > > As an example, ((0$'a'),3 5 9) works because the an array of any type > is accepted, even though ((1$'a'),3 5 9) is an error. On the other > hand, a rare example for an operation that does care about the type of > an empty vector is overtake: try (4{.0$'a') versus (4{.0$0). > > Anyway, I don't know whether it's a good thing or a bad thing to treat > all types of empty arrays the same (their shape does matter, mind > you), but J has been doing that for ever, consistently. > > Ambrus > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > -- Devon McCormick, CFA ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
