in reply to DBI and Eval

A note nearly identical to this was posted to the DBI mailing list yesterday. Was that you?

In any event, the response from those who even benchmarked it is a clear and resounding "BS" call on the "eval slows things down".

Perhaps it's a bad bit of cargo-cult programming. eval-string certainly slows things down. Using $& (not $@) once in a program slows the whole thing down, and once you pay the price once, you don't have to pay it again. Maybe this is a mutated gene from some weird mutant merge of those two statements.

In any event, eval-block subtracts nothing from the execution speed over the price of a normal block (now don't freak out about that either!).

-- Randal L. Schwartz, Perl hacker

Replies are listed 'Best First'.
Re: Re: DBI and Eval
by chromatic (Archbishop) on Dec 20, 2000 at 21:26 UTC
    I wish I could remember where I thought I read that Larry said it, but combining the run-time compilation operator and the exception-handling operator seems to confuse people.

    It makes a certain amount of sense to me, as you don't want a typo in STRING to kill your whole program (and wrapping things in Java-esque try {} - catch {} is a quick way to early RSI or no more error handling), and the idea of context and different operator behavior based on argument list makes sense....

    I think people tend to think of eval as always slow, not going far enough to realize that it's only slow when it compiles something.

Re: Re: DBI and Eval
by Sifmole (Chaplain) on Dec 20, 2000 at 20:37 UTC
    Thanks Merlyn.

    No, the question on the DBI mailing list did not come from me -- I don't even know where the list is, but might be interested in checking it out now. Thanks for the information. I think you are probably right that I merged those two statements into a bad rememberance.

    I appreciate the help.