How does haXe locate types really?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

How does haXe locate types really?

Armén
I have been writing haXe programs for quite some time now, but maybe I
have missed some essentials.

I have a set of classes which I reuse. I put them under my say
"com.foo.bar" package, as in if I have my own Xml class implementation
it would be "com.foo.bar.Xml" etc.

The problem, it seems, is if one of the classes in that package refers
to a say type StringTools that is found as part of standard haXe
distribution, but also as a sibling class "com.foo.bar.StringTools".
There are cases where I would want to actually refer to the standard
haXe class instead. The only way to do so that I have found is to do a
"import StringTools;".

I was wondering - how does one best disambiguate type names? I don't
think there is anything wrong with writing my own StringTools, after
all, I am deliberately not putting it in the global namespace, but I
can't avoid it ending up a sibling of a class that refers to it, can
I...

--
Sent from my washing machine

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: How does haXe locate types really?

Nicolas Cannasse
Le 20/10/2011 12:16, Armén a écrit :

> I have been writing haXe programs for quite some time now, but maybe I
> have missed some essentials.
>
> I have a set of classes which I reuse. I put them under my say
> "com.foo.bar" package, as in if I have my own Xml class implementation
> it would be "com.foo.bar.Xml" etc.
>
> The problem, it seems, is if one of the classes in that package refers
> to a say type StringTools that is found as part of standard haXe
> distribution, but also as a sibling class "com.foo.bar.StringTools".
> There are cases where I would want to actually refer to the standard
> haXe class instead. The only way to do so that I have found is to do a
> "import StringTools;".

Type and identifier resolution is detailed here :
http://haxe.org/manual/modules

Best,
Nicolas


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: How does haXe locate types really?

Viktor Hesselbom-2
To separate them, hopefully this will be implemented in the future: http://code.google.com/p/haxe/issues/detail?id=365#c1 :)

viktor hesselbom



2011/10/20 Nicolas Cannasse <[hidden email]>
Le 20/10/2011 12:16, Armén a écrit :

I have been writing haXe programs for quite some time now, but maybe I
have missed some essentials.

I have a set of classes which I reuse. I put them under my say
"com.foo.bar" package, as in if I have my own Xml class implementation
it would be "com.foo.bar.Xml" etc.

The problem, it seems, is if one of the classes in that package refers
to a say type StringTools that is found as part of standard haXe
distribution, but also as a sibling class "com.foo.bar.StringTools".
There are cases where I would want to actually refer to the standard
haXe class instead. The only way to do so that I have found is to do a
"import StringTools;".

Type and identifier resolution is detailed here :
http://haxe.org/manual/modules

Best,
Nicolas



--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: How does haXe locate types really?

rammserker
I had that problem in a macro I made some days ago. I had the need to use standard Type class and use haxe.macro.Type in the same macro function. So, I made this:

typedef StdType = Type; //This BEFORE importing haxe.macro.Type
import haxe.macro.Type;

So, when I want to refer to standard Type, I use StdType and when I want to refer to haxe.macro.Type, I only use Type. It's too hackish for your code?

Max
0 1 0 | 0 0 1 | 1 1 1



--
haXe - an open source web programming language
http://haxe.org