Beefy Boxes and Bandwidth Generously Provided by pair Networks kudra
XP is just a number
 
PerlMonks  

Re: Re: Re: use Fatal;

by Masem (Monsignor)
on Jan 10, 2002 at 21:31 UTC ( #137778=note: print w/ replies, xml ) Need Help??


in reply to Re^2: use Fatal;
in thread use Fatal;

That is a very ugly use of eval, IMHO.

I've nothing wrong with the eval function, but I'm of the opinion that eval should be used for code that might be generated on the fly (most likely from user input), thus implying the dynamic nature of the perl language. Using eval to evaluate code that is already hard written into the code, on the other hand, seems to be a way to get around compiler/strict or other issues. Certainly there are cases where using eval on hard-coded code is necessary to achieve certain results (for example, if you have a function from a module that would die on failure, but you want to catch this), but otherwise, it reminds me of when I saw C or C++ code that was wrapped in pragmas in order to disable certain compiler features to get their badly written code working properly.

IMO, and I think it will be easier in perl 6, I'd much rather move to an OO-based Exception model as Java has, as it forces you to deal with errors, instead of allowing them to slip. This way, you can deal with errors that might be generated from one part of the code differently than errors from other parts. It does require you to think about these errors from the start, but it ends up improving your overall error-catching of the final program.

-----------------------------------------------------
Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain
"I can see my house from here!"
It's not what you know, but knowing how to find it if you don't know that's important


Comment on Re: Re: Re: use Fatal;
Re^4: use Fatal;
by Aristotle (Chancellor) on Jan 10, 2002 at 21:39 UTC
    Ah. Well personally, I've always thought eval BLOCK should not exist, and that this functionality should be provided by a try BLOCK function. :-)
Re: Re: Re: Re: use Fatal;
by chromatic (Archbishop) on Jan 11, 2002 at 09:15 UTC
    eval BLOCK and eval STRING have as much in common as select FILEHANDLE has with the four-argument version, in my opinion. Since the block contents are known at compile time, they're compiled. Since string contents can't be known at compile time, they must be compiled at run time.

    I do agree that using eval to catch death from the Fatal module is particularly ugly.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://137778]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (5)
As of 2014-04-19 15:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (483 votes), past polls