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:
Eric Brine
Date:
July 5, 2017 17:58
Subject:
Re: How to check if a DateTime is invalid (again - but this timewithout using eval)?
Message ID:
CALJW-qH34XK5EHOm+2ejd-PBPvXmbjFwR+SDCpx9BPYzB6mpxg@mail.gmail.com
On Wed, Jul 5, 2017 at 1:56 PM, Eric Brine <ikegami@adaelis.com> wrote:

> On Wed, Jul 5, 2017 at 1:53 PM, Dave Rolsky <autarch@urth.org> wrote:
>
>> On Wed, Jul 5, 2017 at 12:49 PM, Eric Brine <ikegami@adaelis.com> wrote:
>>
>>> On Wed, Jul 5, 2017 at 12:43 PM, Dave Rolsky <autarch@urth.org> wrote:
>>>
>>>> On Wed, Jul 5, 2017 at 11:27 AM, Bill Moseley <moseley@hank.org> wrote:
>>>>
>>>>> Haven't those issues with eval been addressed in more recent versions
>>>>> of Perl?  Well, that's one issue, but there are others, for example $@
>>>>> being set to a false value.
>>>>>
>>>>
>>> That's kinda hard to do by accident.
>>>
>>>
>>
>> Assuming you are in full control of all the relevant code, yes, I suppose
>> it is. That said, a little extra defensive programming usually seems like
>> the best choice to me. What is gained by discouraging people from using
>> CPAN modules that help avoid corner cases?
>>
>> No, even with that assumption. die(""), die(0) and die(undef) all put
> true values in $@.
>

*without

>perl -E"for ('', 0, undef) { eval { die($_) }; say $@ ? 'true' : 'false' }"
true
true
true

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