Suggestion: #If HasModule(module.path.here)

Monkey Forums/Monkey Programming/Suggestion: #If HasModule(module.path.here)

Skn3(Posted 2013) [#1]
I have a feature suggestion for monkey...

Sometimes it can be hard to decide in monkey how to include accompanying code for a module. Picture this scenario:

I create an xml module that relies on a class called a StringBuffer. I want to make it so the xml module has no dependencies apart from itself so I include a separate StringBuffer file and place it in the xml module directory.

This is fine but lets say I now want to use the StringBuffer in another module. The only way is to split the StringBuffer out into a separate module and have the xml module import that. This is fine if you are writing a framework as you have dependencies flying all over the place. With a standalone modules it is in my opinion good practice to not make the enduser of the module jump-through-hoops inorder to use it.

e.g. I just got this XML module and now it wants a StringBuffer module. Ok I got that, now the StringBuffer module is asking for a Utilities module. Hmmm Ok found that... Bah now its asking for some other module.

It would be nice if we had some preprocessor magic to be able to conditionally compile bits of code dependant on what modules the user has. e.g.



Or in other words can we have ifdefs please :) ?


Belimoth(Posted 2013) [#2]
+1, I was thinking about this the other day.