[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Exception handling in Perl or rather: non-local goto's



On Wed, Jun 22, 2011 at 12:42 PM, Erik Huelsmann <..hidden..> wrote:

>> Can you be specific here?
>
> Yes: studying the pages for Try::Tiny again, their discussion of the
> $@ variable is really about Perl's general "behaviour", meaning I was
> misunderstanding the discussion to be specifically about Try::Tiny and
> my disgust is more with Perl in general than with Try::Tiny.
> Basically, instead of declaring a variable to store the exception
> object into (like e.g. Java in its "catch (<class> <var>) {}"), any
> code can store a value in $@. That means you really can't depend on
> the value of $@ to stay "unclobbered".

One issue with Perl is that a lot of internal variables are exposed to
the developer and can be easily clobbered.  In general, these should
be clobbered sparingly.  In practice this isn't much of an issue
unless folks start using these variable names in their code as general
variables.  Unfortunately, this actually happens in the SQL-Ledger
codebase (and hence our old code) although not with this one in
particular-- the variables incorrectly used there are $a and $b.


> Concluding: Error.pm may be considered unmaintained; switching to
> Try::Tiny seems a good option, with the drawbacks being general Perl
> gotcha's.
>
> It'll take a bit of getting used to, but I guess I'll manage :-)

Ok.  Let's do it then.

Best Wishes,
Chris Travers
>
>
> Bye,
>
>
> Erik.
>
> ------------------------------------------------------------------------------
> Simplify data backup and recovery for your virtual environment with vRanger.
> Installation's a snap, and flexible recovery options mean your data is safe,
> secure and there when you need it. Data protection magic?
> Nope - It's vRanger. Get your free trial download today.
> http://p.sf.net/sfu/quest-sfdev2dev
> _______________________________________________
> Ledger-smb-devel mailing list
> ..hidden..
> https://lists.sourceforge.net/lists/listinfo/ledger-smb-devel
>