[Jprogramming] Datatype of an Object

bill lam bbill.lam at gmail.com
Fri May 1 02:18:38 UTC 2015


use 18!:0 to test for locale name.  eg.
18!:0 <'foo'

Пт, 01 май 2015, Jon Hough написал(а):
> Thanks,
> It seems 18!:2 is more or less what I need.
>  However, it gives an error for Boxed literals.  I think I will need to wrap my verb in a try catch and if itcatches an error I know I am dealing with a standard J type.
> 
> You may be wondering why I would get myself intoa situation where I mistake a boxed literal for an object, but I am creating data structures thatare arrays of both Objects and standard J types. So I need to inspect each item in the structureto see if it is a boxed variable or an object.
> 
> > Date: Thu, 30 Apr 2015 21:06:01 -0400
> > From: HenryHRich at nc.rr.com
> > To: programming at jsoftware.com
> > Subject: Re: [Jprogramming] Datatype of an Object
> > 
> > You could look at the path of the object, with
> > 
> > 18!:2 Obj
> > 
> > Since the path is under the control of the user, you would have to know 
> > what you do with the path to be able to make sense of it.  Often, the 
> > first atom in the path would tell you what you are looking for.
> > 
> > 
> > 
> > An object (called a 'numbered locale' in the J docs) is not a boxed 
> > integer: it's a boxed string that contains all numberics.  You could 
> > check for that with
> > 
> > isnumloc =: *./@:e.&'0123456789'@>
> > 
> > Henry Rich
> > 
> > (Note that it is an error for the first character of a numbered locale 
> > to be '0').
> > 
> > 
> > On 4/30/2015 8:57 PM, Jon Hough wrote:
> > > It seems of I have an Object,e.g.Obj =: conew 'MyClass'
> > > And later I want to get the type of Obj
> > > datatype Obj
> > > this returns "boxed", which is technically correct, but it seems datatype lacks the introspection to look beneath the box at the object.
> > > So is there a way to get the type (i.e. class name if possible) of an object?
> > > e.g. I have some variable Q (which happens to be an instance of MyClass).Is there a way to create a verb, getTypeOf, such that getTypeOf Q
> > > returns 'MyClass'
> > > I couldn't find anything in JForC on this.  At the moment I am finding it difficult to differentiate boxedintegers from objects. 		 	   		
> > > ----------------------------------------------------------------------
> > > 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

-- 
regards,
====================================================
GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
gpg --keyserver subkeys.pgp.net --armor --export 4434BAB3


More information about the Programming mailing list