develooper Front page | perl.perl5.porters | Postings from August 2023

Re: PrePPC - builtin::stringify, builtin::numify

Thread Previous | Thread Next
From:
Dan Book
Date:
August 31, 2023 23:44
Subject:
Re: PrePPC - builtin::stringify, builtin::numify
Message ID:
CABMkAVUxuZO0OMopFGSD_grWsdypUywe3ZD96QX4TRkLRb_Jeg@mail.gmail.com
On Thu, Aug 31, 2023 at 7:23 PM Sam Kington <sam@illuminated.co.uk> wrote:

> On 31 Aug 2023, at 16:56, Paul LeoNerd Evans <leonerd@leonerd.org.uk>
> wrote:
>
> We feel that these are weird cornercases that ideally should behave in
> a more flexible, predictable and consistent manner. It suggests that it
> would be nice to have a real builtin function to request that a value
> get squashed down to a plain string - by invoking the '""' overload if
> necessary. There's already a core OP_STRINGIFY to invoke here, so it
> seems simple enough to wrap it as a new builtin - builtin::stringify.
> If perl provided such a stringify function, then in the presence of the
> "please make join respect overloading" flag that one-argument
> specialcase can be removed, as now that special behaviour is no longer
> required.
>
>
> Frankly, I want this anyway, because I’m tired of remembering whether
> $some_object->method->other_method->some_other_object wants to be
> stringified with ->to_string, ->as_string, ->stringify or whatever.
>
> (And because the object is something I got as a result of a bunch of
> method calls, I can’t just wrap it in double quotes, because interpolation
> won’t kick in.)
>

Agreed, both functions sound generally quite convenient

-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