[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Please translate this easy snip of C++ to Lua
- From: William Roper <lacutis@...>
- Date: Wed, 8 Dec 2004 15:56:13 -0800
Just a guess off the top of my head but:
TRACE = function (x)
print (x .. " : " .. _G[x])
print (x .. " : nil")
then you would call it like so:
foo = "bar"
I'm not sure how to get the name of the parameter, which is why the
"'s are needed there.
On Wed, 8 Dec 2004 14:47:50 -0800, Philip Plumlee
> Ogle this awesome snip of C++:
> #define TRACE_(x) cout << #x ": " << x << endl
> When you use that like this...
> TRACE_(y + z);
> ...the program emits this:
> y + z: 12
> strAnimals: Lemmings
> __LINE__: 69
> Mighty healthy and easy to write debug statements with, huh? Saves a lot
> of keystrokes, huh?
> How do I do that, just as easy to call (meaning without extra "" quotes
> or anything), in Lua?
> home: mailto:firstname.lastname@example.org
> cell: 760 214 2958