2,561
edits
Line 147: | Line 147: | ||
print( cool("foo") ); | print( cool("foo") ); | ||
print( cool(100) ; | 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 = | = Creating Nasal Data Structures = |
edits