in reply to Re: Which phase am I in?
in thread Which phase am I in?

So, Oh Wise Curmudgeon, how would you write code that needs to do things after all compilation is done, but before execution starts?

Real-life situation - I'm working on a class lazyloader (RFC: Object::Proxy (or somesuch) - ignore the Proxy part). The implementation I have chosen is to insert my own constructor in place of the constructor provided by the original author and rename the original one. However, my lazyloader will probably be used at the beginning and the constructor defined a bit later. I cannot rename what isn't there. In addition, I have to do my magic before anything calls the original constructor. What should i do?

Being right, does not endow the right to be rude; politeness costs nothing.
Being unknowing, is not the same as being stupid.
Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

Replies are listed 'Best First'.
Re^3: Which phase am I in?
by tilly (Archbishop) on Nov 20, 2004 at 16:14 UTC
    I wouldn't try to write that code.

    Or if I did, I'd do as some of the modules that you rejected did and not try to retrofit semantics onto the existing module. Instead I'd provide the lazy version of the constructor under a different name.

    And an extension of what I said above is that I won't choose to use modules - including the one that you're writing - that depend on working that way. Because how they are trying to be clever conflicts with how I'd prefer to be clever, so they will be fragile for me.

      Fair enough. What kind of disclaimers should be put into the POD? I'm looking for ways to warn people that this may not work if they get clever in certain ways cause we're being clever in certain ways.

      Being right, does not endow the right to be rude; politeness costs nothing.
      Being unknowing, is not the same as being stupid.
      Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
      Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

Re^3: Which phase am I in?
by BrowserUk (Patriarch) on Nov 20, 2004 at 09:08 UTC

    That's the problem with any code that fmucks with the Symbol table!

    Of course, if you call it "mucking with the symbol table", then you can look down your nose at it, with assurdness that "you shoudln't be doing that".

    If you called "Introspection", or "dynamic programming", then (at least in some languages), you could laud it it as a "useful, valueable, even desirable feature of the language".


    Examine what is said, not who speaks.
    "But you should never overestimate the ingenuity of the sceptics to come up with a counter-argument." -Myles Allen
    "Think for yourself!" - Abigail        "Time is a poor substitute for thought"--theorbtwo         "Efficiency is intelligent laziness." -David Dunham
    "Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon
Re^3: Which phase am I in?
by adamk (Chaplain) on Nov 20, 2004 at 20:36 UTC
    Class::Autouse won't cut it for you as a class lazy-loader?
      That lazyloads the class itself, not instances of the class. Our module creates lazy instances of each object on-the-fly. Maybe it should be called Object::LazyLoader, but it is really intended to work on the class level, so we're looking at Class::LazyLoader.

      (Note: I answered that question in the thread, towards the bottom.)

      Being right, does not endow the right to be rude; politeness costs nothing.
      Being unknowing, is not the same as being stupid.
      Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
      Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.