I was also surprised years ago by the behavior of -: (see http://www.jsoftware.com/pipermail/programming/2006-January/000790.html );
I have been using a conjunction (id) to compare more strictly nouns (and verbs) afterward: '' id (I. 0) 0 '' id (}.0) 0 (1 + 1e_14) id (1 + 1e_15) 0 (<0$0) id (<'') 0 The conjunction is modeled as: tb=. 3!:1 ar=. 5!:1@(<^:(L. = 0:)) id=. '(tb ar''x'') -: (tb ar''y'')' (2 :) ________________________________ From: June Kim <[email protected]> To: Programming forum <[email protected]> Sent: Friday, May 29, 2009 1:36:57 AM Subject: Re: [Jprogramming] confused about different emptiness On Thu, May 28, 2009 at 9:28 AM, Henry Rich <[email protected]> wrote: > > It's 'match', not 'identically equal to'. The problem is that you want > it to mean 'identical', but it doesn't. You are right. However, I have unattentively assumed match as "identical" and have met a couple of bugs that were hard to discover. Maybe all my fault. > > For years I have made the same argument you are making. I have been > ignored. > > I have come to the conclusion that I was wrong. (But I still have an > improvement to suggest below.) > > There are a number of cases where the interpreter treats all empty > operands as identical. It is a good thing to have a primitive that can > calculate that way. > > The biggest defect in having only -: is when the operands are boxed, and > you need to test for exact identity all through the boxing levels. That > is a pain. > > > Suggestion: > > Why not define dyad ~. to mean 'identicalto', in rank, shape, value, AND > TYPE (numeric/literal/symbol). That would solve the problem of > detecting deep equality, and also plug the gap in the language, where > currently there is no primitive to tell whether two nouns are identical. I like the idea. It would be quite useful. > > Henry Rich > > > > June Kim wrote: > > I like weak-typing and see its advantages. > > > > Regardless of that, when two things match each other, it seems natural > > they are replaceable. But in this case, they are not and they behave > > differently(the results do not match) on "take". The programmer could > > make some mistakes from this. > > > > > > On Wed, May 27, 2009 at 10:23 PM, Devon McCormick <[email protected]> > > wrote: > >> Mr. Kim - > >> > >> I disagree. A language like J benefits tremendously from weak-typing and > >> the equivalence of empty arrays is an outcome of this, just like the > >> numerical equivalence of other objects which differ internally, e.g. > >> > >> datatype -.1 > >> boolean > >> datatype 1.1-1.1 > >> floating > >> (-.1)-:1.1-1.1 > >> 1 > >> > >> Obviously, we have a simple way to get at "internal" information, like > >> type. However, it's much more useful to hide internal differences like > >> that > >> for comparison purposes. In my view, the preference of many computer > >> scientists for strong-typing is misguided because, as a practical matter, > >> it > >> complicates things unnecessarily. > >> > >> Regards, > >> > >> Devon > >> > >> On Wed, May 27, 2009 at 4:25 AM, June Kim <[email protected]> wrote: > >> > >>> '' ;&datatype I.0 > >>> +-------+-------+ > >>> |literal|integer| > >>> +-------+-------+ > >>> > >>> It seems like there are different emptiness for every datatype but > >>> they all match same. I think it's more natural they don't match. > >>> > >>> On Wed, May 27, 2009 at 5:08 PM, June Kim <[email protected]> wrote: > >>>> ''-: I. 0 > >>>> 1 > >>>> {. '' > >>>> > >>>> {. I.0 > >>>> 0 > >>>> > >>>> Shouldn't '' -:&{. I.0 be true, given ''-:I.0? > >>>> > >>> ---------------------------------------------------------------------- > >>> 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 > >> > > ---------------------------------------------------------------------- > > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
