<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta content="text/html;charset=UTF-8" http-equiv="Content-Type"></head><body ><div style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10pt;"><div>Hi, <br></div><div><br></div><div>I am wondering if this is possible: <br></div><div><br></div><div>I've a structure with data and function pointer, for example:<br></div><div><br></div><div>mystruct.data = 5;<br></div><div>mystruct.func =%myfun<br></div><div><br></div><div>calling mystruct.func() will call myfun with the input of mystruct.data. <br></div><div><br></div><div>To put it in example, this is what I tried:<br></div><div><br></div><div>// define an inline function<br></div><div>--> deff('x = myfunc(y)', 'x = y.data + 1') <br></div><div><br></div><div>// create my_struct with field 'data' = 2<br></div><div>--> my_struct.data = 2<br></div><div>my_struct =<br></div><div><br></div><div> data = 2<br></div><div><br></div><div>// try to call myfunc with the my_struct -->o k<br></div><div>--> myfunc(my_struct)<br></div><div>ans =<br></div><div><br></div><div> 3.<br></div><div><br></div><div>// Define a "pointer" to myfunc<br></div><div>--> %ptr = myfunc<br></div><div>%ptr =<br></div><div><br></div><div>[x]=%ptr(y)<br></div><div><br></div><div>// Try to use %ptr to call the function --> ok<br></div><div>--> %ptr(my_struct)<br></div><div>ans =<br></div><div><br></div><div> 3.<br></div><div><br></div><div>// assign %ptr to my_struct.func<br></div><div>--> my_struct.func = %ptr<br></div><div>my_struct =<br></div><div><br></div><div> data = 2<br></div><div> func: myfunc(y) => [x] (3 lines)<br></div><div><br></div><div><br></div><div>// I still can call the function with this, but it looks redundant as "my_struct" appear twice..<br></div><div>--> my_struct.func(my_struct)<br></div><div>ans =<br></div><div><br></div><div> 3.<br></div><div><br></div><div>// How to I modified the codes so that calling below line will automatically find the my_struct.data?<br></div><div>--> my_struct.func()<br></div><div>at line 2 of function myfunc<br></div><div><br></div><div>Undefined variable: y<br></div><div><br></div><div><br></div><div>Thanks for advice.<br></div><div><br></div><div>Regards,<br></div><div>Chin Luh<br></div></div><br></body></html>