using feature

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

using feature

Fabien ANTOINE
I'm playing with the using feature and I like it!

But it seems that the compiler search the class to use only from the
root package.

So if I have an architecture like that:
package/
    SomeClass.hx
    SomeOtherClass.hx

And in SomeClass.hx I have the following code:
using SomeOtherClass;

The compiler doesn't find SomeOtherClass and I have to write:
using package.SomeOtherClass;

It could be fine to allow the usage of the first code.
What do you think about this?

Fabien

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

Re: using feature

Nathan Rixham
Fabien Antoine wrote:

> I'm playing with the using feature and I like it!
>
> But it seems that the compiler search the class to use only from the
> root package.
>
> So if I have an architecture like that:
> package/
>     SomeClass.hx
>     SomeOtherClass.hx
>
> And in SomeClass.hx I have the following code:
> using SomeOtherClass;
>
> The compiler doesn't find SomeOtherClass and I have to write:
> using package.SomeOtherClass;
>
> It could be fine to allow the usage of the first code.
> What do you think about this?
>
> Fabien
>

have you done an import? (first thing that springs to mind)

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

Re: using feature

Fabien ANTOINE
Nathan Rixham a écrit :
>
> have you done an import? (first thing that springs to mind)
>
 No I don't, but normally if SomeOtherClass is in the same package than
SomeClass, I should not have to import it?


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

Re: using feature

Blue Sans douze
Yes, you shouldn't have.
It looks like a minor bug.

Where can I find doc on using feature ? I've never heard about it.
Blue112


2009/6/11 Fabien Antoine <[hidden email]>
Nathan Rixham a écrit :
>
> have you done an import? (first thing that springs to mind)
>
 No I don't, but normally if SomeOtherClass is in the same package than
SomeClass, I should not have to import it?


--
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: using feature

David Bergman
In reply to this post by Fabien ANTOINE
On Jun 11, 2009, at 12:09 PM, Fabien Antoine wrote:

> Nathan Rixham a écrit :
>>
>> have you done an import? (first thing that springs to mind)
>>
> No I don't, but normally if SomeOtherClass is in the same package than
> SomeClass, I should not have to import it?

This is how it works: the main types, which is the class with the same  
name as the module, of the modules (the .hx file) in the same package  
(as the code trying to use them) are automatically brought into the  
scope. But, auxiliary types defined in such modules are not. These can  
include enum's or helper types. To bring *all* types defined in a  
module into scope, one has to do import the module explicitly, even  
though it resides in the same package.

AFAIK, the haXe documentation does not explicitly deal with the notion  
of "module," but should do so.

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

Re: using feature

Nicolas Cannasse
In reply to this post by Fabien ANTOINE
Fabien Antoine a écrit :

> I'm playing with the using feature and I like it!
>
> But it seems that the compiler search the class to use only from the
> root package.
>
> So if I have an architecture like that:
> package/
>     SomeClass.hx
>     SomeOtherClass.hx
>
> And in SomeClass.hx I have the following code:
> using SomeOtherClass;
>
> The compiler doesn't find SomeOtherClass and I have to write:
> using package.SomeOtherClass;

Yes, this is right now very similar to the way "import" works.

Nicolas

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