packages - Introduction to packages in Sncode.
A package is a container that may be used to group a set of related symbols (functions, constants, classes) together.
Package declaration must begin with the keyword package, followed by its name, and must end with the keyword endp.
Package names can contain either letters [a-zA-Z], numbers [0-9] or _ but cannot begin with a number. It is recommended to avoid numbers and use the UpperCamelCase convention to name your packages.
For instance:
package Exemple
e = "!";
function hello()
return "Hello ";
endf
function world()
return " World";
endf
endp
In order to use a package that is in another file, you have to import it using the %include method:
%include "/path/to/your/package/exemple.sn";
To call a function defined in a package, you have to use the operator :: between the package name and the function name:
a = Exemple::hello() .+ Exemple::world() .+ Exemple::e;
Calling a symbol (variable or function) from the same package :
package A
function f1()
return "f1";
endf
function f2()
return A::f1() .+ ", f2";
endf
endp
Written by Jean-Georges Guenard, <jg@sednove.com>
Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin commodo. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis.
1.0 2014-09-09 21:24:14 laplante@sednove.com