cancel
Showing results for 
Search instead for 
Did you mean: 

Is the callbacks example correct in "Q for Mortals"?

dmitri14
New Contributor
rsvp:{[arg;cb] show arg; (neg .z.w) (cb; 43); show `done;}
On client:
(neg h) (`rsvp; 42; `echo)
The server displays 42 as advertised, but the client responds with 'echo, no 43 shows up.
Anything wrong with the example? Any way to fix it?
2 REPLIES 2

jsawyer
New Contributor
New Contributor
Dmitri,

You are seeing this error because you did not define the "echo" function on the client side.

We turn to the client side and create echo to serve as the function called back for this demonstration.

q)echo:{show x} / on client

q)h:hopen 10223
q
)neg[h] (`rsvp;42;`echo)

q
)'echo

q)echo:{show x} / on client
q)neg[h] (`rsvp;42;`echo)
q)43

Regards,
Jorge

Thank you for the catch, Jorge!

The same section defines `echo also on the server,
it would have been less confusing to have a different name.

How comes, no error was reported when `echo is not defined?