![]() |
OK, for you advanced LPC coders:
If I have a global string variable, say 't' in an object, I can reference it's value within a closure: f = lambda( ({}), ({#'write,({#'t}) }) ); funcall(t); This will do write(t); My question: Is it possible to dynamically specify/bind the name of the variable. I've tried various ways of using symbol_function() and quote() with no success, and my gut feeling is that it isn't possible. Anyone have the definitive answer? |
|
yes i did, thanks for pointing that out.
|
If you want to bind to an arbitrary global variable in the same object as the closure is being constructed in, it's simple:
[code] string x; closure f; x = whatever_variable_name; f = lambda(({}),({#'write,({#'apply,symbol_variable(x) })})); [/quote] The key here is remembering to run the symbol returned by symbol_variable through apply or funcall. |
|
All times are GMT -4. The time now is 09:19 PM. |
Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright Top Mud Sites.com 2022