在这种情况下,它们似乎是主函数的局部函数,首先声明这一点很重要——您在函数(主函数或子函数)中放入的所有内容都是从上到下进行求值的。
默认“top2bottom”顺序的异常是从已经计算过的函数调用的。
应用时,自上而下的评估顺序适用。lsp文件,它从上到下逐个评估所有声明的函数。
然后,一旦所有主函数和子函数都被声明/求值,您就可以运行主函数,而不用担心未定义的(子)函数。
注意,当解释器评估一个函数时,它只是检查它的内容——在这里,您可能会收到“输入时额外的左/右参数”错误,
但它不运行函数(这意味着运行/检查内部的所有计算):
- _$ (defun test ( / ) [color="darkgreen"]; <- The function /main/[/color]
- [color="darkgreen"]; These things will be evaluated from top to bottom order, starting from this row
- ; <code> ... bla bla[/color]
- (MyUndefinedFunction [color="darkgreen"]; <- a subfunction we use inside of our main, but we didn't define it anywhere (so the main will try to run it, but will crash because it was never evaluated)[/color]
- ) [color="darkgreen"]; <- our main should crash at this evaluation, and will stop going thru the next bottom lines [/color]
- [color="darkgreen"] ; <code> ... bla bla
- ; we could define/evaluate the subfoo here, but since we already attempted to run it before defining it, we will recieve an error
- ; (defun MyUndefinedFunction ( / ) <code> .. bla bla)[/color]
- )[color="darkgreen"]; defun test[/color]
- TEST [color="darkgreen"]; <- This means our main function evaluated successfuly (no syntax errors)[/color]
- _$ (test) [color="darkgreen"]; <- Now we run it, it will step through all the evaluations inside (TOP to BOTTOM order)[/color]
- Error: [color="red"]no function definition[/color]: MYUNDEFINEDFUNCTION [color="darkgreen"]; <- it doesn't recognise it, because we never define it (or we tried to define it after we ran it)[/color]
- _1$
- _$ test [color="darkgreen"]; <- lets check if our main is defined/evaluated[/color]
- #<USUBR @000000b646f7c570 TEST>[color="darkgreen"] ; <- yes it is[/color]
- _$ MyUndefinedFunction [color="darkgreen"]; <- lets check if our subfunction is defined/evaluated[/color]
- nil [color="darkgreen"]; <- no its not[/color]
谢谢 |