谢谢,我想这需要大量的写作/练习才能达到一个不错的水平。
你不需要道歉,Rlx-这只是你理解代码的方式。
你的工作给我留下了深刻的印象,这让我好奇,并激励我根据自己的理解重新编写代码。
对我来说,将相同的变量传递给不同的子函数,并将作为一个整体程序的相同子函数连接在一起,这非常令人困惑。
所以我试着遵循Michael Puckett的写作风格,在那里你首先声明了处理输入并返回一些东西所需的子函数。
然后你只需要运行整个程序。。即。:
- (defun test ( / foo1 foo2 foo3 *error* r ) ; Localise our required subfunctions that help out with the overall performance
- (defun foo1 ( input1 ) ; subfunction on-the-fly
- ... ; say if point is provided, prompt for a selection and return it, else nil
- )
- (defun foo2 ( input2 ) ; subfunction on-the-fly
- ... ; say if a SS is provided, prompt to be filtered by Layer, using dialog with listbox, return list of enames, else nil
- )
- (defun foo3 ( input3 ) ; subfunction on-the-fly
- ... ; say if a list of enames is provided, erase them - this is the last evaluation and I don't care what it returns
- )
- (defun *error* (m) ...) ; I use the *error* function as a separator between my on-the-fly subfuns and the main program
-
- (and ; Main Program - nice and clean: only one variable is processed by 3 different subfunctions
- (setq r (getpoint)) ; r = nil ? -> stop evaluating
- (setq r (foo1 r)) ; r = nil ? -> stop evaluating
- (setq r (foo2 r)) ; r = nil ? -> stop evaluating
- (setq r (foo3 r)) ; r = nil ? -> doesn't matter, we're done
- ); and
- ); defun test
- (defun foo4 ( input ) ; subfunction that is used more globally - i.e. its required in (foo2) and (foo3)
- ...
- ); defun foo4
此外,我还尝试使用一种合适的代码格式,这样每个计算都可以很容易地被同化,但这有时会花费太多的行
(只需检查并比较Marko_Ribar和Lee Mac之间的任何大/中代码——一个更喜欢长的一行,另一个写着12行相同的求值)。
我指的是格式风格,因为我不会像你那样编写1-2行的临时dcl代码——只是不是我的写作类型。
谢谢分享,有空的时候我会查的。 |