Author Topic: Reactors - (lambda) as a callback function?  (Read 129 times)

0 Members and 1 Guest are viewing this topic.

Grrr1337

  • Bull Frog
  • Posts: 314
Reactors - (lambda) as a callback function?
« 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:
« Last Edit: March 20, 2017, 08:17:33 am by Grrr1337 »

roy_043

  • Swamp Rat
  • Posts: 1431
  • BricsCAD 16
Re: Reactors - (lambda) as a callback function?
« Reply #1 on: March 20, 2017, 10:21:35 am »
The documentation is pretty clear:
callback_function is a symbol representing a function
« Last Edit: March 20, 2017, 10:29:46 am by roy_043 »

Grrr1337

  • Bull Frog
  • Posts: 314
Re: Reactors - (lambda) as a callback function?
« Reply #2 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: