develooper Front page | perl.perl5.porters | Postings from July 2018

Re: [perl #133357] Time::Piece overloading will not acceptoverloaded objects

Thread Previous | Thread Next
From:
Maurice Aubrey
Date:
July 13, 2018 05:06
Subject:
Re: [perl #133357] Time::Piece overloading will not acceptoverloaded objects
Message ID:
23538_1531458368_5B48333F_23538_45_1_CAMjjn=Ge2TjGUcDkx-5oGV47D6WDjZhPKM78MRRrED51VSmAtg@mail.gmail.com
On Thu, Jul 12, 2018 at 9:05 PM Dan Book <grinnz@gmail.com> wrote:

> On Thu, Jul 12, 2018 at 11:38 PM Maurice Aubrey <maurice.aubrey@gmail.com>
> wrote:
>
>>
>> I have a proof-of-concept here:
>>
>> https://github.com/Dual-Life/Time-Piece/compare/master...mla:feature/blessed?expand=1
>>
>> It's using Scalar::Util, which I'm not sure is okay or not for a core
>> module. But it's still passing all tests and satisfies my use case.
>>
>
> I don't think we need looks_like_number or reftype here either. reftype
> will violate the encapsulation of an object that's passed, you should only
> check that if it's not blessed (in which case you can just just check if
> ref eq 'ARRAY'). The looks_like_number check shouldn't be necessary
> (looks_like_number has some interesting edge cases), you can just use it as
> a number and depend on appropriate overloading, Perl will emit the
> appropriate warning or error if it doesn't end up being numeric.
> Time::Seconds's overload means we don't need to special case that as you
> correctly fixed.
>

Thanks. I've been chatting with Samuel on this. Added your comment here:
https://github.com/Dual-Life/Time-Piece/issues/42

Maurice


>
> -Dan
>

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