bartdewilde 发表于 2022-7-6 14:25:10

(defun cb:...)

hello
 
i'm starting with autocad lisp
 
i've learnd that you start a routine with
 
(defun c:name ....)
 
 
but now i've found a program that start with
 
(defun cb:hdis (/ld)
 
this comes back with the variables
 
if (= (type cb:ld) 'str
 
i understand the meanig of this code exept what te cb: means
 
can someone tell me what's the difference between defun c: and defun cb:

VVA 发表于 2022-7-6 14:37:21

By analogy to this article, I have written article on use of a code from a forum in Russian, where has a little expanded the description.
As I not so well know English, therefore I will take advantage of machine translation. I hope, it will be clear, and if is not present, me will correct.
 
 
In your case it is function and it needs to be caused so: (cb:hdis)

Commandobill 发表于 2022-7-6 14:44:45

I believe I've seen that lisp before. "cb:" doesnt actually do anything. That code is just a function. if you were to type in "hdis" as a command it wouldnt do anything. but if you were to use it like this (cb:hdis) it would run. Why they named it that way is unknown to me but im sure they had their reasons.

Commandobill 发表于 2022-7-6 14:54:10

Too little too late it seems. Good description VVA

Lee Mac 发表于 2022-7-6 14:56:14

Nice once VVA, but, yes, I believe its just irresponsible function naming...

rkmcswain 发表于 2022-7-6 15:09:45

 
I wouldn't bet on it... I do this all the time. Useful for identification.

David Bethel 发表于 2022-7-6 15:14:01

 
 
I agree.I use function name prefixes all of the time.My preference is to use an underscore delimiter , but a colon is just as valid.My $0.02-David

Lee Mac 发表于 2022-7-6 15:20:03

 
You mean using the function syntax as a prefix for sub_routines - I suppose its good for reference, but the function begins with a c..: I suppose it could confuse the LISP novice...

rkmcswain 发表于 2022-7-6 15:32:32

Possibly, but still nothing wrong with it. I do this sometimes within the same file. Say my file (and main function is named) CHTXT - i might name my internal functions things like:

(defun chtxt:myfunc ()(blah_blah))
Of course, like David says, just my 2¢.
页: [1]
查看完整版本: (defun cb:...)