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

[perl #131910] feature to interpolate method calls in double-quotishstrings

From:
Justin Case via RT
Date:
August 22, 2017 20:37
Subject:
[perl #131910] feature to interpolate method calls in double-quotishstrings
Message ID:
rt-4.0.24-5269-1503434256-258.131910-15-0@perl.org
On Wed, 16 Aug 2017 11:06:13 -0700, mauke- wrote:

-----------------------------------------------------------------
> [Please describe your issue here]
> 
> I'd like to be able to interpolate method calls in double-quotish
> contexts.
> Method calls have become increasingly common in e.g. Moo/Moose based
> classes
> where you get an accessor for every attribute. The current workarounds
> ("$foo "
> . $obj->bar . " baz", "$foo ${\$obj->bar} baz") are unnecessarily
> ugly.
> 
> (Maybe coderef calls via ->( ) should also be interpolated. This would
> mean any
> use of "$foo->..." gets interpolated, no matter whether '...' is [ X
> ], { X },
> ( X ), or an identifier.)
> 
> This is not backwards compatible so I'd hide it behind a feature flag
> (which
> could be enabled by default after e.g. 'use v5.28' or 'use v5.30').

List interpolation is probably easier to use: 
    "$foo @{[$obj->bar]} baz"

---
via perlbug:  queue: perl5 status: new
https://rt.perl.org/Ticket/Display.html?id=131910



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