Discussion:
closures global var dynamic reference
(too old to reply)
t***@csfb.com
2003-07-17 09:43:42 UTC
Permalink
Question for the more advanced LPC coders:

I can reference a global string variable 'x' within a closure like
this:
f = lambda( ({}),({#'write,({#'x}) }) );
Then
funcall(f);
write()s the value of x.

Is it possible to dynamically specify the name of the variable ie "x"
in the above expression, using symbol_function() or quote() or another
EFUN?
I've tried all the possible methods I can think of but none seem to
work.
My gut feeling is it's not possible. Can anyone prove me wrong? :)

Cheers, T
Lars Duening
2003-07-17 17:34:06 UTC
Permalink
Post by t***@csfb.com
I can reference a global string variable 'x' within a closure like
f = lambda( ({}),({#'write,({#'x}) }) );
Then
funcall(f);
write()s the value of x.
Is it possible to dynamically specify the name of the variable ie "x"
in the above expression, using symbol_function() or quote() or another
EFUN?
symbol_variable() would be the way to go. However, whether that's a good
idea design-wise is a different question.
Post by t***@csfb.com
I've tried all the possible methods I can think of but none seem to
work.
Try again, and if it doesn't work, post your code (reasonably
condensed).
t***@csfb.com
2003-07-21 08:22:49 UTC
Permalink
Post by Lars Duening
Post by t***@csfb.com
I can reference a global string variable 'x' within a closure like
f = lambda( ({}),({#'write,({#'x}) }) );
Then
funcall(f);
write()s the value of x.
Is it possible to dynamically specify the name of the variable ie "x"
in the above expression, using symbol_function() or quote() or another
EFUN?
symbol_variable() would be the way to go. However, whether that's a good
idea design-wise is a different question.
Post by t***@csfb.com
I've tried all the possible methods I can think of but none seem to
work.
Try again, and if it doesn't work, post your code (reasonably
condensed).
heh...that'd be why then....my driver is too old, no symbol_variable() !
Lars Duening
2003-07-21 17:18:02 UTC
Permalink
Post by t***@csfb.com
Post by Lars Duening
symbol_variable() would be the way to go. However, whether that's a good
idea design-wise is a different question.
Post by t***@csfb.com
I've tried all the possible methods I can think of but none seem to
work.
Try again, and if it doesn't work, post your code (reasonably
condensed).
heh...that'd be why then....my driver is too old, no symbol_variable() !
Out of curiosity: which driver version are you using?

Loading...