Adding your own functions with version 4.4b - question


Hi ,

I’ve used the template , and added a function to start a touch display connected to ulisp.
In the first version it worked but directly after the board always did a reset.
So I looked further and I tried a return(0); at the end of the function.
The functio expects no input , and return no output.
Now it works , but I wonder if this is correct ? If I call the function it works and returns a NIL on the prompt.
Here’s the code :

object *fn_touch_begin (object *args, object *env) {
  (void) env;
  int nargs = listlength(args);
  if (nargs > 0) {
     error2(PSTR("wrong number of arguments"));
  } else touch.begin(); 


Lisp functions always need to return a value. If there is no sensible value to return, functions usually return nil, with:

return nil;

What you’ve written is equivalent to this.