Import question

Monkey Forums/Monkey Programming/Import question

Shagwana(Posted 2015) [#1]
If I Import a file that does not exist, should an error be thrown?


ImmutableOctet(SKNG)(Posted 2015) [#2]
If you import a module that doesn't exist, you'll get a message highlighting this fact. It's just a warning, so the program will compile if the functionality from them missing module wasn't directly used. You can check if a module was imported by using the preprocessor to define an "implementation variable" normally. The result is a variable being defined if the import was successful, meaning you can check if a module exists.


Shagwana(Posted 2015) [#3]
No warning is given from what I see (v83b) (debug on).

If you tried to use anything from inside the import elsewhere in your program, then that generally gives you a error. I just spent far too long scratching my head over this error, turns out I made a boob on the Import line.

I think it would be much wiser to halt compiling if something you are importing is does not exist.


Nobuyuki(Posted 2015) [#4]
Linker halts are a curse; if Trans doesn't spit out a warning already, then a warning sounds like it would be sufficient to solve this....


Shagwana(Posted 2015) [#5]
Logging as a bug!


Samah(Posted 2015) [#6]
I never knew this problem even existed. I agree it's a bug.