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

0 Members and 1 Guest are viewing this topic.

Grrr1337

  • Swamp Rat
  • Posts: 812
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 »
(apply ''((a b c)(a b c))
  '(
    (( f L ) (apply 'strcat (f L)))
    (( L ) (if L (cons (chr (car L)) (f (cdr L)))))
    (72 101 108 108 111 32 87 111 114 108 100)
  )
)
vevo.bg

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
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

  • Swamp Rat
  • Posts: 812
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:
(apply ''((a b c)(a b c))
  '(
    (( f L ) (apply 'strcat (f L)))
    (( L ) (if L (cons (chr (car L)) (f (cdr L)))))
    (72 101 108 108 111 32 87 111 114 108 100)
  )
)
vevo.bg