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

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

Thread Previous | Thread Next
From:
Sam Kington
Date:
August 31, 2023 23:23
Subject:
Re: PrePPC - builtin::stringify, builtin::numify
Message ID:
CF95F0DB-7204-467F-88D2-80C3E27026B8@illuminated.co.uk
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.)

Sam
-- 
Website: http://www.illuminated.co.uk/



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