User Tools

Site Tools


ch2_1_defun

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
ch2_1_defun [2022/03/31 04:54] adminch2_1_defun [2022/03/31 04:57] (current) admin
Line 19: Line 19:
 If function body contains more expressions, all are evaluated sequentially (once the function is called), but only the output of the last one is returned from the function (this behavior is due to implicit ''PROGN''). If function body contains more expressions, all are evaluated sequentially (once the function is called), but only the output of the last one is returned from the function (this behavior is due to implicit ''PROGN'').
  
-====== Optional parameters ====== +=== Optional parameters ===
  
 Since LabLISP version 1.3, it is possible for user to define function with variable number of parameters, using a symbols ''&OPTIONAL'' and ''&REST'' in the list of parameters.   Since LabLISP version 1.3, it is possible for user to define function with variable number of parameters, using a symbols ''&OPTIONAL'' and ''&REST'' in the list of parameters.  
Line 64: Line 63:
  
 The mandatory, optional and rest paramters can be combined. Order of the keywords ''&OPTIONAL'' and ''&REST'' must be kept. That means we can have any number of mandatory parameters, then ''&OPTIONAL'' keyword, after any number of optional parameters, with or without initializers, then ''&REST'', which must be followed by exactly one symbol. The mandatory, optional and rest paramters can be combined. Order of the keywords ''&OPTIONAL'' and ''&REST'' must be kept. That means we can have any number of mandatory parameters, then ''&OPTIONAL'' keyword, after any number of optional parameters, with or without initializers, then ''&REST'', which must be followed by exactly one symbol.
 +
 +=== Lexical closure ===
  
 Functions have lexical closure. In simple terms, it means that when called, the function body expressions are evaluated in the environment, where the function was defined, and not in the environment where called.  Functions have lexical closure. In simple terms, it means that when called, the function body expressions are evaluated in the environment, where the function was defined, and not in the environment where called. 
ch2_1_defun.1648724098.txt.gz · Last modified: 2022/03/31 04:54 by admin

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki