I think this is not even a metaprogramming issue so much as a
programming environment one.  I mean, if your editor doesn't make it
easy to stick a # at the beginning of a bunch of lines with one
action, and likewise remove them later, you need to get a new editor.
:)

On 8/21/06, Joshua Hoblitt <[EMAIL PROTECTED]> wrote:
On Mon, Aug 21, 2006 at 12:06:36AM +0100, Andrew Suffield wrote:
> On Sun, Aug 20, 2006 at 03:55:56PM -0600, Luke Palmer wrote:
>
> > Why would you care about introducing a new lexical scope?  You would
> > care about that if you used a variable you declared in the commented
> > code in the code below it, which is broken.
>
> Typically because you have several versions that you want to switch
> between, and you'd rather add a few characters of comment rather than
> spend the time rearranging the code to use ifs or subs or
> something. It's something you might do when debugging or experimenting
> (especially under time pressure) - at least, that's how I use '#if 0'
> in C.

The more I think about this issue the more I realize that this is really
a very simple case of metaprogramming.  Which got me thinking about more
sophisticated compile time flow control.  I imagine that defining
something like a compile time switch switch statement is possible with
the existing macros.  Would anyone like to take a shot at defining a
macro to do this?  Is it possible to jump to something outside of a
macros input that is also evaluated at compile time?

> Using <<'#END' (or rather, q:to'#END') is actually not that bad an
> idea... it'd work in most places where #{} would give trouble. Unless
> anybody has any better ideas, that could be a useful idiom to
> remember.

Using heredocs for commenting code out is slightly undesirable as it
would create a branch that has to be tested at runtime.  One would hope
that the compiler would note the conditional on a constant and throw the
heredoc out as dead code but it certainly feels untidy.

-J

--




--
Mark J. Reed <[EMAIL PROTECTED]>

Reply via email to