develooper Front page | perl.datetime | Postings from July 2017

Re: How to check if a DateTime is invalid (again - but this timewithout using eval)?

Thread Previous | Thread Next
From:
Thomas Klausner
Date:
July 3, 2017 15:11
Subject:
Re: How to check if a DateTime is invalid (again - but this timewithout using eval)?
Message ID:
20170703151118.lzbi4dccbsc3y6xf@plix.at
Hi!

On Mon, Jul 03, 2017 at 10:00:52AM +0200, Binarus wrote:
 
> My main problem was that from my readings I got the impression that even
> the block eval might be problematic (please see my answer to Thomas
> Klausner's first post if you are interested what made me believe so).

Just for a bit more backgroud:

block eval indeed had some not-totally-implausible corner cases, as 
listed here:
https://metacpan.org/pod/Try::Tiny#BACKGROUND

AFAIK at least some of them were fixed in Perl 5.14:
http://blog.twoshortplanks.com/2011/06/06/unexceptional-exceptions-in-perl-5-14/

I personally don't like Try::Tiny, because it changes how 'return' works 
inside an eval (well, try), and I'm too stupid to remember this change 
(and it bit me a few times). OTOH I never (even on ancient Perls had any 
problem with three issues mentioned in Try::Tiny - Background (but then 
"die Dummen hams Gl├╝ck" as a local saying goes)


And regarding using exceptions or not: I don't think you have a choice 
here. You will always encounter exceptions (disk full, DB-Server 
crashed, ...), so you might as well get used to them and incorporate 
them in your toolkit. I know nothing about .NET, so maybe exceptions are 
horrible there. But in Perl they work quite well, IMO...

Greetings,
domm


-- 
#!/usr/bin/perl                              http://domm.plix.at
for(ref bless{},just'another'perl'hacker){s-:+-$"-g&&print$_.$/}

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About