|
|||||||
This is a discussion on "Advanced LPC question" in the Top Mud Sites MUD Coding forum : 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?... |
|
You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our MUD community today! If you have any problems with the registration process or your account login, please contact us. If you are a registered member of the old TMS forums, please click here
|
![]() |
|
|
LinkBack | Thread Tools |
|
|
#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
|
cool. first decent LPC question i see in topmudsties
shame that i even couldnt understand fully question and no way can answer it. just were wondering if you didnt mean funcall(f); instead of funcall(t); |
|
|
|
|
|
#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
![]() |
Yep, thanks for that.
Basically my problem boils down to: Our driver is too old, it doesn't have symbol_variable(). No wonder I couldn't get it to work eh |
|
|
|
![]() |
| Thread Tools | |
Advanced LPC question - Similar Threads
|
||||
| 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 |
|
|