file organisation
You are here :

Sub nodes

Recent changes
Site plan


Nosica source files are organised in packages. You declare a Nosica source file belonging to a package by using the keyword 'package', like in :

 package net.nosica.lang;
 class Object {

The package declaration must be the first line of the source file. The package net.nosica.lang means that the source must be located in the directory net/nosica/lang of your root source distribution. The compiler will enforce it. More on this later.

Class name

On the previous example, we declared a class named Object. That means that our source file must be named Object.nos. The file name is case sensitive.

Therefore, the complete path must be : $SOURCE_PATH/net/nosica/lang/Object.nos


When you want to use a class or an interface you previously coded, you can do it in a number of means

Using an import declaration

Simply use an 'import' declaration. Imports must be located between the package declaration and your class declaration.

Example :

 package net.nosica.lang;
 import net.nosica.lang.string;
 class MyString {
   public sub fromString(const string str) {

Using an import declaration in the class itself

Let's say we have several classes having the same name in different packages. You can import their symbol in your class directly using the second 'import' form :

 class Sample {
   import project1.somePackage.A A1;
   import project2.someOtherPackage.A A2;

Default imports

When you start a Nosica source file, there are two directories that are always imported.

That is, in the example

 package project1.somePackage;
 class SomeClass {

It is as you had written :

 package project1.somePackage;
 import net.nosica.lang;      // import all Nosica classes from package net.nosica.lang
 import project1.somePackage; // import all Nosica classes from package project1.somePackage
 class SomeClass {

Setting the source path

The source path is a special variable that must be passed to the compiler. It is a list of paths the compiler will look in when resolving a TypeName.

You can set source_path by

Propulsed by Wiclear