package - Define a package in sncode
package name; ... endp;
A package can be used to defined function in a differente namespace.
Starting with sncode 5.42, variables can also be defined for the package.
To access a function with a package, the following syntax is used:
package_name :: function_name(...);
To access a variable with a package, the following syntax is used:
package_name :: variable
Inside a package, you don,t have to put the package_name except in a function as in:
package test; config = 5; function f() "config="; test::config; endf endp
It is possible to omit the package name for a variable. In that case, the variable is in a namespace of its own
and can be used as is a package name was specify as in:
package a;
::config = { "sql" : "select username from sn_users" };
function f()
res = sql(::config.sql);
::config.res = res.rows[0];
endf
endp
a::f();
::config.res.username;
package a;
config = { "sql" : "select username from sn_users" };
function f()
res = sql(a::config.sql);
a::config.res = res.rows[0];
endf
endp
a::f();
a::config.res.username;
Written by Pierre Laplante, <laplante@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