| 1 | = Use = |
| 2 | |
| 3 | {{{ |
| 4 | use <namespace> |
| 5 | use <namespace> from <library-name> |
| 6 | }}} |
| 7 | |
| 8 | Specify a namespace and its contents to make available to this module. |
| 9 | |
| 10 | When using the first form if the compiler cannot immediately locate |
| 11 | the namespace [[BR]] |
| 12 | (i.e if its not in the list of default loaded libraries)[[BR]] |
| 13 | it will look for a (platform dependent) library-name of the same form as |
| 14 | the namespace. |
| 15 | |
| 16 | For .Net thats the namespace with '.dll' appended |
| 17 | |
| 18 | {{{ |
| 19 | use Foo.Bar |
| 20 | # On .Net will look for namespace in Foo.Bar.dll if not already available |
| 21 | }}} |
| 22 | |
| 23 | If the filename of the library differs from the namespace, you can specify |
| 24 | it with the second form. [[BR]] |
| 25 | <library-name> can be a simple identifier, qualified identifier (Foo.Bar) |
| 26 | or a string literal. |
| 27 | |
| 28 | {{{ |
| 29 | use Foo.Bar from SomeLib |
| 30 | }}} |
| 31 | You can put single or double quotes around the file name if its components |
| 32 | are not legal identifiers.[[BR]] |
| 33 | |
| 34 | (for example, the filename has a space or punctuation mark in it). |
| 35 | {{{ |
| 36 | use Foo.Bar from "My Lib" |
| 37 | }}} |
| 38 | |
| 39 | |
| 40 | == Platform == |
| 41 | On .Net <library-name> will refer to a .Net Assembly or dll. |
| 42 | |
| 43 | No ".dll" extension is expected (or allowed) in any of this syntax. |
| 44 | |
| 45 | In .Net the list of default loaded libraries is: |
| 46 | * System |
| 47 | * ?? |
| 48 | * !CobraCore (Cobra.Lang.dll) |
| 49 | |
| 50 | |
| 51 | == Examples == |
| 52 | {{{ |
| 53 | use System.Windows.Forms |
| 54 | use System.Drawing |
| 55 | }}} |
| 56 | |
| 57 | == Notes == |
| 58 | |
| 59 | In most cases this syntax means you dont need to specify the commandline |
| 60 | -reference switch |
| 61 | |
| 62 | With !MyProg.cobra containing |
| 63 | ... |
| 64 | use Foo.Bar |
| 65 | |
| 66 | Instead of compilation by |
| 67 | |
| 68 | cobra -reference:Foo.Bar !MyProg.cobra |
| 69 | |
| 70 | you can just say: |
| 71 | |
| 72 | cobra !MyProg.cob |