On 8/20/06, Andrew Suffield <[EMAIL PROTECTED]> wrote:
On Sun, Aug 20, 2006 at 10:50:31AM -1000, Joshua Hoblitt wrote:
> > #{
> >    if $baz {
> >        $foo.bar
> >    }
> > }
> >
> > To uncomment, remove the # before the {.
>
> This is exactly the type of construct that I had in mind.  A couple of
> questions. Is code inside of a #{}:
>
>     - parsed and required to be syntacticly correct?
>     - does it still appear in emitted code?
>     - what happens when a goto tries to enter into this block
>       or a nested sub is invoked?
>     - will the optimizer spend time on this block?

The important question here is this one:

 - when 'uncommented', is it a no-op?

Which isn't true for #{}/{}, because {} introduces new lexical
scope. It's still a pretty good idea, but it's not as good as the C
preprocessor. if (0) has the same problem. Pod doesn't. Anybody able
to think up a non-pod construct that doesn't affect the code it wraps?
(Solutions which involve complicated modules are acceptable, so long
as the usage is not complicated and there is no run-time penalty)

Well, I think you are being too picky.

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.  If you are still not
satisfied, you might try:

   <<'#EOC';
   .. commented out code ..
   #EOC

And put the code back into effect by commenting out the <<'#EOC' line.
Of course, that changes the last statement evaluated, which isn't
good because the code above it (which is supposed to have code below
it making it forget about its last statement evaluated) must maintain
its last statement evaluated.

You can't use Pod, because you have to insert two characters instead
of changing one to uncomment some code.

And, since you are open to using complicated modules, I suppose using
a module like:

   use C::Preprocessor::IfZero;

is out of the question because its implementation would only be a
couple of lines.

Yep, I think we need to add a feature to perl to support commenting
and uncommenting code easily.

Luke

Reply via email to