Boo Imports & New Usages
Okay, since I have started thinking about using:
import file from anotherFile.boo
It occurred to me that there are plenty of reasons to want to do similar things. And boo is flexible enough to make some interesting things with it.
What about bringing in WSDL definition at compile time?
import webservice from "http://localhost/who/is.there" as WhoIsThereService
And then writing a small compiler step that does all the rest.
Usually the first twenty or so lines of my my Windsor.boo file are just import statements, they really make it harder to read, why not split them to another file?
import all from imports.boo
I can probably think of a few other interesting things to do with it, as well.
Comments
This definitely sounds interesting....
I agree, this sounds interesting. The WS example in particular. However, the last example looks more like an #include to me. Boo needs a preprocessor, and writing a compiler step that just copies imports from one file to another is very specialized overkill, when all you need is a preprocessor supporting #include and #define.
I wouldn't call it preprocessor, not when it is has knowledge of the language AST.
Also, overkill?
That is about 30 lines of code.
My point is that you don't need knowledge of the AST. Why write a "load that file, look for import statements and copy them here" when all you need is "load that file and copy it here"?
Avish,
Because then I get into the usual pre-processor errors. In other words, the code that I write and the code that the compiler sees are two different steps.
It also means that I now need to think about the file structure.
Imagine:
"file_to_include.boo"
import X
import Y
someVar = 0
"including_file.boo"
include file_to_include.boo
import Z
print "Hi"
Using a preprocessor will produce uncompilable code.
This has something similar, I actually use this for deployment with some additions that make it work like running a .bat file
http://www.members.optusnet.com.au/~olegshilo/
Comment preview