Small import issue, Solved

Monkey Forums/Monkey Programming/Small import issue, Solved

zoqfotpik(Posted 2014) [#1]
I have a small quibble about imports. It took me a little while to realize that imports from different files produce different namespaces according to the filename. But what if I don't want everything namespaced by file? Eg. I have a particle class, which is now in a file particle.monkey. Is there any way I can avoid having to refer to it by particle.particle.method?

This question was also asked two months ago here http://www.monkey-x.com/Community/posts.php?topic=7947&post=78854 and was never addressed.

Edit: Well, I figured out that I can solve the problem with Alias. Cool enough.

Import particle

Alias Tparticle = particle.particle

Function Main:Int()
	Local testparticle:Tparticle = New Tparticle
end


I just ask these questions here because it causes me to solve the problem magically myself two minutes after I post.

Oh, and now for many other cases it works the way I expected and I don't run into namespace issues and I don't need Alias. Presumably this is because the filename is not the same as my classname. Fine, fine, whatever.


ziggy(Posted 2014) [#2]
Its solved by using proper Monkey naming convention which is filenames start with lowercase and clases star uppercase


zoqfotpik(Posted 2014) [#3]
Yeah, I figured that out. Works now.

I'm just curious if this is documented anywhere. I've certainly never seen it in the docs and it's something that could give a newbie a hell of a time.


tiresius(Posted 2014) [#4]
Well there is this line in the doc, not sure how clear it is for module naming conventions.
"When accessing identifiers in imported modules, Monkey allows you to omit the module scope as long as there are no 'clashes' between identifiers in multiple modules."


zoqfotpik(Posted 2014) [#5]
Yeah... It took me about two hours of looking and not understanding why it wasn't working, then as usual as soon as I posted the question here the solution came to me, within maybe 2 minutes... At first I was trying to use Alias but then I realized that for some of them it worked whether I used alias or not.