What are best practices/conventions for coding a Cobra library?
I'm getting compilation errors for having no main method. Is there an option to suppress compilation errors in this event? Should I simply insert an empty class with an empty main method to supress the warning?
I have cloned down projects listed in the wiki and none of them compile unfortunately, the code must run on an older version of Cobra. If they don't compile I'm not sure if I should follow their conventions.
I'm specifically getting errors that other classes cannot be found although they exist in the same namespace. I tried using import but I'm getting this error : " error: Expecting use, assembly, namespace, class, interface or enum, but got "import"." What is odd is that the keyword is listed in the source here : http://cobra-language.com/trac/cobra/br ... pecs.cobra
Thanks
Forums
Creating a library
9 posts
• Page 1 of 1
Re: Creating a library
Use -target:lib to create a library:
For namespaces, use them in each file:
We'll have to take a look at the external projects and get them updated.
- Code: Select all
cobra -target:lib foo.cobra
-->
foo.dll & foo.dll.mdb or foo.pdb
For namespaces, use them in each file:
# foo.cobra
namespace A.B
class Foo
pass
# bar.cobra
namespace A.B
class Bar
pass
- Code: Select all
cobra -target:lib foo.cobra bar.cobra
We'll have to take a look at the external projects and get them updated.
- Charles
- Posts: 2515
- Location: Los Angeles, CA
Re: Creating a library
So popped the compiled lib files into a lib directory and then created a test file as follows. I'm getting the following compilation error : test.cobra(1): error: Cannot find namespace "A.B".
Also, how do you use classes from other modules? Both foo and bar are declared to be inside the same namespace but I can't access each other.
Compilation returns : bar.cobra(8): error: Cannot find "Foo".
use A.B
class Test
def main
f = Foo()
Also, how do you use classes from other modules? Both foo and bar are declared to be inside the same namespace but I can't access each other.
# bar.cobra
namespace A.B
class Bar
def main
t = Foo()
Compilation returns : bar.cobra(8): error: Cannot find "Foo".
- Sovietaced
- Posts: 9
Re: Creating a library
Disregard. Compiling all the files at once solves any inter-module dependencies.
- Sovietaced
- Posts: 9
Re: Creating a library
Glad you got through it. The "import" keyword was reserved simply in case we wanted to use it in the future. It's not currently used for anything.
"namespace Foo" declares a namespace
"use Foo" uses another namespace
"namespace Foo" declares a namespace
"use Foo" uses another namespace
- Charles
- Posts: 2515
- Location: Los Angeles, CA
Re: Creating a library
Charles wrote:Glad you got through it. The "import" keyword was reserved simply in case we wanted to use it in the future. It's not currently used for anything.
"namespace Foo" declares a namespace
"use Foo" uses another namespace
The only compiled language I've used extensively is Java and I guess I just took it for granted all the magic that Eclipse does
- Sovietaced
- Posts: 9
Re: Creating a library
There is a new wiki page for creating and using libraries in cobra
(off LibraryTopics --> Libraries in Cobra )
If you get a chance pls have a look and see if it would have clarified your understanding of how to use and make libraries in cobra..
(off LibraryTopics --> Libraries in Cobra )
If you get a chance pls have a look and see if it would have clarified your understanding of how to use and make libraries in cobra..
- hopscc
- Posts: 632
- Location: New Plymouth, Taranaki, New Zealand
Re: Creating a library
hopscc wrote:There is a new wiki page for creating and using libraries in cobra
(off LibraryTopics --> Libraries in Cobra )
If you get a chance pls have a look and see if it would have clarified your understanding of how to use and make libraries in cobra..
That is perfect man! Really awesome thanks, clears everything up.
- Sovietaced
- Posts: 9
Re: Creating a library
And thus we advance.
- hopscc
- Posts: 632
- Location: New Plymouth, Taranaki, New Zealand
9 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 23 guests