Ayende @ Rahien

Unnatural acts on source code

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

Shane Courtrille
10/10/2007 10:58 PM by
Shane Courtrille

This definitely sounds interesting....

Avish
10/11/2007 01:37 PM by
Avish

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.

Ayende Rahien
10/11/2007 01:43 PM by
Ayende Rahien

I wouldn't call it preprocessor, not when it is has knowledge of the language AST.

Ayende Rahien
10/11/2007 01:43 PM by
Ayende Rahien

Also, overkill?

That is about 30 lines of code.

Avish
10/12/2007 10:29 AM by
Avish

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"?

Ayende Rahien
10/12/2007 10:57 AM by
Ayende Rahien

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:

"filetoinclude.boo"

import X

import Y

someVar = 0

"including_file.boo"

include filetoinclude.boo

import Z

print "Hi"

Using a preprocessor will produce uncompilable code.

pb
10/12/2007 11:24 AM by
pb

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/

Comments have been closed on this topic.