Wiki

Use

Specify a namespace and its contents to make available to this module.

Grammar

use <namespace>
use <namespace> from <library-name>

When using the first form if the compiler cannot immediately locate the namespace
(i.e if its not in the list of default loaded libraries)
it will look for a (platform dependent) library-name of the same form as the namespace.

For .Net thats the namespace with '.dll' appended

use Foo.Bar 
# On .Net will look for namespace in Foo.Bar.dll if not already available

If the filename of the library differs from the namespace, you can specify it with the second form.
<library-name> can be a simple identifier, qualified identifier (Foo.Bar) or a string literal.

use Foo.Bar from SomeLib

You can put single or double quotes around the file name if its components are not legal identifiers.
(for example, the filename has a space or punctuation mark in it).

use Foo.Bar from "My Lib"

Platform

On .Net <library-name> will refer to a .Net Assembly or dll.

No ".dll" extension is expected (or allowed) in any of this syntax.

In .Net the list of default loaded libraries is:

  • System
  • System.Collections.Generic
  • System.IO
  • System.Text
  • Cobra.Core

Examples

use System.Windows.Forms 
use System.Drawing

Notes

In most cases this syntax means you dont need to specify the commandline -reference switch as the dll can be found through the common naming of the use target and the dll.

With MyProg.cobra containing ...

    use Foo.Bar

Instead of compilation by

cobra -reference:Foo.Bar MyProg.cobra

you can just say:

cobra MyProg.cobra