Whilst I applaud the code you have shared, note that quoting every nested expression in the supplied list is not quite achieving the same result as both mine & MP's example functions, in which certain specific expressions are evaluated immediately as part of the function definition (e.g. references to objects, such as the active document object), whilst others are evaluated when the function itself is evaluated.
Consider the difference in the result of the following function definitions, as may be illustrated through the use of defun-q:
Thank you for pointing and explaining that out Lee!
Now I do remember the nostalgic confusion I got years ago when I was trying to understand the manual 'diseval-uation' technique:
where I thought the logic was that everything should be recursively 'quotted' and 'nestedly-list-capsulated', but then seeing
(vla-get-activedocument (vlax-get-acad-object)) within the body, instead of (list (quote vla-get-activedocument) (list (quote vlax-get-acad-object))) .
Completely forgot about this detail while writing the sub ^^.
*sigh* ...I'm beginning to think people believe "obfuscation" equals "better".
'obfuscation' is not the thing I'm after in this thread, although it resulted in such (if I remember there was a thread somewhere here related to protecting code with obfuscation).
Reason that I do not categorise it as such, was because of Roy's
explanation :
(defun LM:acdoc nil
(eval (list 'defun 'LM:acdoc 'nil (vla-get-activedocument (vlax-get-acad-object))))
(LM:acdoc)
)
When first called, Lee's LM:acdoc function redefines itself. The new definition directly returns the active document object and is therefore a (minute) bit faster than the less complex function proposed by Aftertouch.
(setq obj (vlax-ename->vla-object (car (entsel))))
(mp-benchmark
'(
(mp-get-owner-1 obj)
(mp-get-owner-2 obj)
)
)
Elapsed milliseconds / relative speed for 32768 iteration(s):
(MP-GET-OWNER-2 OBJ).....1125 / 1.35 <35% faster>
(MP-GET-OWNER-1 OBJ).....1516 / 1.00 <slowest>
(did multiple tests, observed everything from 29-41% speed increase).
TLDR: Wifey says speed isn't everything.
An aside, I prefer encapsulating objects when applicable, eliminates superfluous processing and it's tidy; win.
Thanks for providing a benchmark example, MP - helps me understand better what Roy ment back in 2017.
Still wondering were you encapsulating manually (thats the correct term, right: encapsulation?)
*Thinking that there could be a regex alternative to my suggestion*
Glad to see that ronjonp gained one more brain cell.
BTW I've modified it a bit to avoid quoting numbers or T symbols.