[Jprogramming] data type of empty , empty

Henry Rich HenryHRich at nc.rr.com
Thu Oct 19 22:59:32 HKT 2006


> Why does it matter to you?

Because an empty list of boxes is different from an
empty list of numbers, and code can work or not work
depending on which result is produced by , .

Also, the behavior as described below violates the
principle of J that the user doesn't need to concern
himself with the type of numbers.  As implemented, a
complex list produces numbers, while an integer
list produces boxes.

It is very important that empties be handled consistently,
and not just by pretending that the type doesn't matter,
so that code doen't have to check for empty operands.

Henry Rich

> -----Original Message-----
> From: programming-bounces at jsoftware.com 
> [mailto:programming-bounces at jsoftware.com] On Behalf Of Roger Hui
> Sent: Thursday, October 19, 2006 9:15 AM
> To: Programming forum
> Subject: Re: [Jprogramming] data type of empty , empty
> 
> 
> 
> 
> ----- Original Message -----
> From: bill lam <bbill.lam at gmail.com>
> Date: Wednesday, October 18, 2006 6:56 pm
> Subject: [Jprogramming] data type of empty ,  empty
> 
> > I tested appending empty to empty of different data types.
> >   (3!:0) (0$0) , 0$0
> > 1
> >   (3!:0) (0$0) , 0$' '
> > 2
> >   (3!:0) (0$2) , 0$' '
> > 4
> >   (3!:0) (0$2.2) , 0$' '
> > 8
> >   (3!:0) (0$u:'a') ,~ 0$a:
> > 131072
> >   (3!:0) (0$u:'a') , 0$a:
> > 131072
> >   (3!:0) (0$' ') ,~ 0$a:
> > 32
> >   (3!:0) (0$1r3) , 0$a:
> > 128
> >   (3!:0) (0$0) , 0$a:
> > 32
> >   (3!:0) (0$2) , 0$a:
> > 32
> >   (3!:0) (0$2.2) , 0$a:
> > 8
> >   (3!:0) (0$1j2) , 0$a:
> > 16
> > 
> > At first, I thought data type is the larger of 3!:0, but a counter 
> > example in
> > the last line. It also seems data type does not depend on leftmost 
> > or rightmost
> > position. Does anyone know the rule of deriving the data type?
> 
> 
> ----------------------------------------------------------------------
> For information about J forums see 
> http://www.jsoftware.com/forums.htm



More information about the Programming mailing list