From: "Brian F. Feldman" Date: 2001-09-24T04:15:28+09:00 Subject: [ruby-talk:21609] Re: Please translate this easy snip of C++ to Ruby Phlip wrote: > Ruby Users: > > Ogle this awesome snip of C++: > > #define TRACE_(x) cout << #x ": " << x << endl > > When you use that like this: > > TRACE_(y + z); > TRACE_(strAnimals); > TRACE_(__LINE__); > > 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 Ruby? You don't. Ruby Is Not C. It doesn't use a magic preprocessor. If you want something not be evaluated, you have a funny way of expressing it by writing them as plain variables and expecting some kind of magic to not evaluate them. There are a couple magic things like that already, and there shouldn't be any more. What is hard about puts("foo(blah): #{foo(blah)}")? C++ definitely doesn't have the ability to do something like evaluating code embedded in strings, does it? -- Brian Fundakowski Feldman \ FreeBSD: The Power to Serve! / green@FreeBSD.org `------------------------------'