Top Mud Sites Forum Return to TopMudSites.com
  Top Mud Sites Forum > Mud Development and Administration > MUD Coding
Read-only archive
The Top Mud Sites forum is closed.
Posting, registration and logins are disabled.

 
Old 07-17-2003, 05:59 AM   #1
[email protected]
New Member
 
Join Date: Mar 2003
Posts: 23
Tamsyn@zebedee.org is on a distinguished road
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?
 
Old 07-17-2003, 07:29 AM   #2
markizs
Member
 
Join Date: Jan 2003
Location: Riga, Latvia
Posts: 36
markizs is on a distinguished road
 
Old 07-17-2003, 07:31 AM   #3
[email protected]
New Member
 
Join Date: Mar 2003
Posts: 23
Tamsyn@zebedee.org is on a distinguished road
yes i did, thanks for pointing that out.
 
Old 07-17-2003, 07:02 PM   #4
JilesDM
Member
 
Join Date: Nov 2002
Posts: 66
JilesDM is on a distinguished road
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.
 
Old 07-21-2003, 04:41 AM   #5
[email protected]
New Member
 
Join Date: Mar 2003
Posts: 23
Tamsyn@zebedee.org is on a distinguished road
 



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


All times are GMT -4.


Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Style based on a design by Essilor
Copyright Top Mud Sites.com 2022