[haXe] Using Type.typeof
John Eriksson
john at insane.se
Wed Aug 1 16:21:31 CEST 2007
Well actually:
if(Type.typeof(h) == TObject){
and not
if(Std.typeof(h) == TObject){
also note that you don't need ValueType.TObject...
You must also do import Type;
anyway, thank you for your help on this. This looks alot better than that
string conversion I was doing.
John
2007/8/1, Benjamin Dasnois <benjamin.dasnois at gmail.com>:
> Sorry for spamming,
> or even better:
> if( Std.typeof(fieldData) == ValueType.TObject)
> {
> }
>
> should be ok. And that's a lot better because it doesn't rely on
> converting from Enum to String.
>
> On 8/1/07, Benjamin Dasnois <benjamin.dasnois at gmail.com> wrote:
> > Ok, so maybe this could do the trick:
> > if( Std.typeof(fieldData) == "TObject")
> > {
> > }
> >
> > Please, refer to my precedent message to know what will be considered
> > as an Object or no.
> >
> > Nicolas, could you tell us if I was right or wrong thinking typeof is
> > dealing with runtime types (since they can differ from platform to
> > another) while Std.is is dealing with pure haXe types?
> >
> > On 8/1/07, John Eriksson <john at insane.se> wrote:
> > > Well... maybe I'm doing this all wrong from the start, if I am please
> > > correct me :-)
> > >
> > > What I want to do is just to check if a certain value that is passed
> > > to a method is an
> > > Object or not...
> > >
> > > 2007/8/1, Benjamin Dasnois <benjamin.dasnois at gmail.com>:
> > > > Why do you want to use TObject? It's not really an haXe type...it's a
> > > > runtime type. Is there any reason you really want to use it?
> > > >
> > > > On 8/1/07, John Eriksson <john at insane.se> wrote:
> > > > > Yeah, that's what I was thinking too, yes the compiler complains if I
> > > > > try to declare
> > > > > a variable of type TObject... I just dont know how to include
> > > > > TObject...how do I do that
> > > > > with an import statement? Where is TObject declared? As far as I can
> > > > > tell, the TObject
> > > > > is declared in Type.hx, but Type is always available without an
> > > > > import... shouldn't
> > > > > TObject be as well? (TObject is a type declared by the haXe language).
> > > > >
> > > > > 2007/8/1, Benjamin Dasnois <benjamin.dasnois at gmail.com>:
> > > > > > Maybe it works but you're using another function...
> > > > > > Are you sure you've included what's necessary for your TObject type to
> > > > > > be accessible? For example, does the compiler complains if you try to
> > > > > > declare a variable of type TObject in the same function?!
> > > > > >
> > > > > >
> > > > > >
> > > > > > On 8/1/07, John Eriksson <john at insane.se> wrote:
> > > > > > > I tried it, but it gives me this error when compiling:
> > > > > > >
> > > > > > > ../frameworks.git/InsaneFramework/se/insane/core/model/INSModelArray.hx:39:
> > > > > > > characters 24-31 : Unknown identifier : TObject
> > > > > > >
> > > > > > > currently I am doing:
> > > > > > >
> > > > > > > if(Std.string(Type.typeof(fieldData)) == 'TObject')
> > > > > > >
> > > > > > > is that really how it is supposed to work?
> > > > > > >
> > > > > > > 2007/8/1, Benjamin Dasnois <benjamin.dasnois at gmail.com>:
> > > > > > > > Hello,
> > > > > > > > Try this :
> > > > > > > > if (Std.is(fieldData, TObject))
> > > > > > > > {
> > > > > > > > //fieldData is of type TObject
> > > > > > > > } else
> > > > > > > > {
> > > > > > > > //fieldData is not of type TObject
> > > > > > > > }
> > > > > > > >
> > > > > > > > Regards,
> > > > > > > > Benjamin DASNOIS
> > > > > > > >
> > > > > > > > On 8/1/07, John Axel Eriksson <john at insane.se> wrote:
> > > > > > > > > If I'd like to compare the type of a value and check if it is
> > > > > > > > > TObject, how would I do that?
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > I have tried:
> > > > > > > > >
> > > > > > > > > if ( Type.typeof(fieldData) == TObject )
> > > > > > > > >
> > > > > > > > > if ( Type.typeof(fieldData) == "TObject" )
> > > > > > > > >
> > > > > > > > > if ( Type.typeof(fieldData) == ValueType.TObject )
> > > > > > > > >
> > > > > > > > > and some other ways but none of these are correct. I guess this is a
> > > > > > > > > simple one, but I can't seem to figure it out.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > /J
> > > > > > > > >
> > > > > > > > > --
> > > > > > > > > haXe - an open source web programming language
> > > > > > > > > http://haxe.org
> > > > > > > > >
> > > > > > > >
> > > > > > > > --
> > > > > > > > haXe - an open source web programming language
> > > > > > > > http://haxe.org
> > > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > > haXe - an open source web programming language
> > > > > > > http://haxe.org
> > > > > > >
> > > > > >
> > > > > > --
> > > > > > haXe - an open source web programming language
> > > > > > http://haxe.org
> > > > > >
> > > > >
> > > > > --
> > > > > haXe - an open source web programming language
> > > > > http://haxe.org
> > > > >
> > > >
> > > > --
> > > > haXe - an open source web programming language
> > > > http://haxe.org
> > > >
> > >
> > > --
> > > haXe - an open source web programming language
> > > http://haxe.org
> > >
> >
>
>
> --
> DASNOIS Benjamin
> http://bwebspace.wordpress.com
>
> --
> haXe - an open source web programming language
> http://haxe.org
>
More information about the Haxe
mailing list