in reply to Optimizing away calls to functions defined in eval

When you eval() something, aren't you just running the compiler? Seems like all the same optimizations should occur.

When I build auto-accessors for use in mod_perl, I do it in a BEGIN so that they will be in shared memory.

  • Comment on Re: Optimizing away calls to functions defined in eval

Replies are listed 'Best First'.
Re: Re: Optimizing away calls to functions defined in eval
by dragonchild (Archbishop) on Oct 16, 2001 at 17:37 UTC
    I've tried the BEGIN idea and it's not working. Could it be because I've got the evals in a function that is found through inheritance?

    ------
    We are the carpenters and bricklayers of the Information Age.

    Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

      By "not working", do you mean that the memory doesn't seem to be shared? If you're loading the module in your startup.pl and defining methods in a BEGIN, it should work. Or are you talking about something totally different?
        I've got a slightly more complex structure than that.

        I've got my main script. It's brings in Foo. Foo inherits from Bar. Within Bar lives define_attributes(), which creates the attributes and accessor functions. Foo calls Foo->define_attributes() with the attributes it wants to define.

        Now, everything works just fine (without things like BEGIN, etc). I wanted to find out if there was a way I could optimize away the function calls while still being able to define them on-the-fly.

        ------
        We are the carpenters and bricklayers of the Information Age.

        Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.