![]() |
#1 |
New Member
Join Date: Mar 2003
Posts: 23
![]() |
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? |
![]() |
![]() |
![]() |
#2 |
Member
|
|
![]() |
![]() |
![]() |
#3 |
New Member
Join Date: Mar 2003
Posts: 23
![]() |
yes i did, thanks for pointing that out.
|
![]() |
![]() |
![]() |
#4 |
Member
Join Date: Nov 2002
Posts: 66
![]() |
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. |
![]() |
![]() |
![]() |
#5 |
New Member
Join Date: Mar 2003
Posts: 23
![]() |
|
![]() |
![]() |
![]() |
Thread Tools | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Advanced Building - Area Development | Rundvelt | MUD Builders and Areas | 20 | 09-16-2004 07:18 PM |
Advanced Plot Development Course | Brody | MUD Announcements | 0 | 11-14-2003 11:51 AM |
Advanced Stat Systems | Eagleon | Advanced MUD Concepts | 5 | 06-28-2003 06:26 PM |
Advanced LPC | snowfruit | MUD Coding | 4 | 11-08-2002 10:12 AM |
expanded advanced mud search | Burr | Bugs and Suggestions | 0 | 05-24-2002 08:44 PM |
|
|