in reply to Constant subroutines thoughts

Okay, I see this well documented in perlsub.pod at "Constant Functions", so I badly searched in documentation.

Sorry

But the point still remains.

Courage, the Cowardly Dog.
PS. Something fishy is going on there, or my name is Vadim Konovalov. And it's not.

Replies are listed 'Best First'.
Re: Re: Constant subroutines thoughts
by Elian (Parson) on Jun 08, 2002 at 18:22 UTC
    Which point? That perl's optimizer is pretty simple-minded? It is. Or that some modules aren't using the most constant constant subs that they can? They're not.

    The modules in question probably need some updating. OTOH, you can, at runtime, override the non-constant constant subs, while you can't override the constant constant subs. (Whether the module authors were considering this or not is up in the air--they might've, or they might just have misread the docs)

      I consider optimizer to be really good.

      That "point" is about modules, especially core ones, which could be slightly improved.

      But even more point for me is to learn from what I wrote and to write a bit better code by not using "almost constant subs" :)

      Courage, the Cowardly Dog.
      PS. Something fishy is going on there, or my name is Vadim Konovalov. And it's not.

        The optimizer's actually really, really primitive. That's OK--optimizing perl's a non-trivial task, and in many cases it's just not worth the effort to do the optimization. Saving 10 seconds of runtime isn't worth it if the optimizer needs to run for 30 seconds to get it.

        Your point about modules is well taken, though not entirely obvious from the original node. :)