Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re^3: the try/catch example from "Programming Perl" analyzed

by hardburn (Abbot)
on Aug 19, 2004 at 19:58 UTC ( #384430=note: print w/replies, xml ) Need Help??

in reply to Re^2: the try/catch example from "Programming Perl" analyzed
in thread the try/catch example from "Programming Perl" analyzed

I have yet to find a case in which I would want to throw an object.

I have. Specifically, I want to do different things for different errors, and extract information from it. For instance, Exception::Class provides full information about the uid/gid, package, file, line number, stacktrace, pid, and so on. Sure, it'd be possible to encode all that into a single string, but the extraction process isn't as easy. Further, you might want to provide some information to the user, and send more details to the developer. It's much easier (and safer) to do that with an object than trying to munge a string.

Besides Java code doing the same thing is usualy several times longer than its Perl conterpart so I don't think these three or four additional lines matter. That is unless you program Java in perl.

It's not just the extra lines, but the extra level of indentation. Like I said, Java programmers typically operate with 4-space indents, because they know they're going to take a lot more space for indentation than other langs (and also because the identifiers tend to be much longer). However, most Perl programmers can easily get away with 8-space indents. As such, every extra level of indentation is a big deal.

Other people have given solutions which get rid of that extra level. My prefered is to place the string into an exception object and then handle it like any other exception..

"There is no shame in being self-taught, only in not trying to learn in the first place." -- Atrus, Myst: The Book of D'ni.

  • Comment on Re^3: the try/catch example from "Programming Perl" analyzed

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://384430]
[marto]: yeah, so our hackerspace, we run mailman. that's a public discussion list, not a weekly buy our crap marketing list, people can unsubscribe at any time. What they can't do is delete their mails from the archive, or from the inboxes of our hundreds of user
[Corion]: marto: I'm not sure on how to treat mail archives. I think you could either set an auto-deletion timespan or an auto-anonymisation timespan if you wanted to do it right.
[Corion]: For PM, I think we'll create a user "gdpr", who gets assigned the nodes of users who want to give up their user status here.

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2018-05-22 08:26 GMT
Find Nodes?
    Voting Booth?