Changes

Jump to: navigation, search

Howto:Extend Nasal

612 bytes added, 04:07, 16 May 2009
m
Argument Processing
print( cool("foo") );
print( cool(100) ;
 
 
A common way to evaluate parameters passed to extension functions, looks like this:
static naRef f_foo (naContext c, naRef me, int argc, naRef* args) {
naRef param1 = argc > 0 ? args[0] : naNil();
naRef param2 = argc > 1 ? args[1] : naNil();
naRef param3 = argc > 2 ? args[2] : naNil();
//further parameter processing
return naNil;
}
 
This will basically look for 3 parameters, and assign them accordingly - if they are not available, they will just be assigned nil using the naNil() calls (the next step would be to check if the parameters have the right types using the naIs* helpers).
= Creating Nasal Data Structures =
2,561
edits

Navigation menu