Skip to end of metadata
Go to start of metadata

Boo scripts have a set structure you need to follow to avoid errors when compiling. All of the items are optional, but order of the items is not:

The structure is like:

  • module docstring
  • namespace declaration
  • import statements
  • module members: class/enum/def declarations
  • main code executed when script is run
  • assembly attributes

For example:

There is one issue with the above structure, however. What if you are creating a library (dll), and you want to have "global" properties or fields? Also, what if you want to do some things when your dll is loaded by another application?

Example use:

Now in Boo, you can do this by specifying a "global" class for your module. You tell the Boo compiler to use your class as the global, module-wide class by adding a [Module] attribute:

Also in Boo you can define which method the compiler should use as the main entry point method. This is useful for example when you want to add an attribute (like STAThread) to the main method. This main method can be anywhere in your boo script, or you can put it inside your main module class if you want to combine both of these techniques.

  • No labels


  1. If you use [assembly: AssemblyTitle('foo')], don't forget to import System.Reflection

    Or you will get compiler error when you compile your program. 

  2. Since ModuleAttribute is obsolete, you should ignore the section devoted to it.