David Garamond wrote:
print “there are %d eggs in the basket now.” % (eggs)
will be optimized away.
is there similar thing in ruby? or do i have to use a preprocessor?
Interpreter switch ‘-d’ and $DEBUG may help you. This may be good for
tiny script, but running large application with -d switch is often so
verbose. I recommands you to use some logger library.
sorry for the late response. my problem is, i want to insert lots of
string literals (sort of embedded documentation, but will be read by
other scripts) which i don’t want to include in the optimized version.
in python, if i do this:
def foo(self, x, y):
self.__doc__x = "…some longish string…"
self.__doc__y = "…some also longish string…"
self.doc_spec1 = “…yet another string…”
then the debug portion along with the literals will be removed so they
don’t take up memory. i don’t seem to be able to do this with ruby,
except by using a preprocessor.
I’m a newbie and I still haven’t read any serious book, just been
browsing code --I’ve code prefixed with a D that appeared to be debug
code, so maybe you’d do
D self.__doc__x …
D self.__doc__y …
and then ruby -d yourscript.rb
Giuseppe “Oblomov” Bilotta
Axiom I of the Giuseppe Bilotta
theory of IT:
Anything is better than MS