TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Grrr1337 on March 20, 2017, 08:10:37 AM

Title: Reactors - (lambda) as a callback function?
Post by: Grrr1337 on March 20, 2017, 08:10:37 AM
Hi guys, reactor dummy asking:
Is it possible to set lambda function as a callback function to a reactor?

I've did some simple test and it failed:
Code - Auto/Visual Lisp: [Select]
  1. _$ (vlr-Mouse-reactor "test" ; include the new reactor
  2.   (list
  3.     (cons :vlr-beginDoubleClick
  4.       (lambda (rtr arg)
  5.         (alert (strcat "\nrtr " (vl-prin1-to-string rtr) "\narg " (vl-prin1-to-string arg)))
  6.       )
  7.     ); cons
  8.   ); list
  9. ); vlr-mouse-reactor
  10.  
  11. Error: bad argument type: (or stringp symbolp): #<USUBR @0000005c713bba70 -lambda->
  12. _1$

Although:
Code - Auto/Visual Lisp: [Select]
  1. _$ (equal
  2.   (type Dclick:callback)
  3.   (type
  4.     (lambda (rtr arg)
  5.       (alert (strcat "\nrtr " (vl-prin1-to-string rtr) "\narg " (vl-prin1-to-string arg)))
  6.     )
  7.   )
  8. )
  9. T
  10. _$

But before I fully gave up on this idea, I wanted someone else that perhaps tried this long time ago to comfirm that this is impossible?
 :thinking:
Title: Re: Reactors - (lambda) as a callback function?
Post by: roy_043 on March 20, 2017, 10:21:35 AM
The documentation is pretty clear:
Quote from: http://docs.autodesk.com/ACD/2011/ENU/filesALR/WS1a9193826455f5ff1a32d8d10ebc6b7ccc-679d.htm
callback_function is a symbol representing a function
Title: Re: Reactors - (lambda) as a callback function?
Post by: Grrr1337 on March 20, 2017, 10:41:22 AM
Thanks Roy!
I thought that I could fool this with lambda, instead of defining a simple named function.  :uglystupid2: