[Kc] thinking about interpolation of accessors

Sterling Hanenkamp sterling at hanenkamp.com
Thu Feb 20 14:02:24 PST 2014


I have been known to use this:

"the blurf field is @{[$self->blurf]}\n"

It's ugly and wouldn't be something I use in production, but it does the
job when I'm in hurry.


On Thu, Feb 20, 2014 at 2:42 PM, David Nicol <davidnicol at gmail.com> wrote:

>
> A common Perl newbie error is to try to use an object accessor method in
> an interpolative context and expect to get the value, like so
>
>      DEBUG and print "the blurf field is $self->blurf\n";
>
> which (of course) doesn't work, because blurf is a method call, not a
> syncactic container access like $self->{blurf}.
>
> An extension to Perl that would allow that to work would have to hook back
> into the interpolation process.
>
> Anyone for tinkering under perl's hood towards defining a package attribute
> that would indicate that method syntax interpolates?
>
>
>
> --
>
> "Sing, cuckoo, sing.
> Death is a-comin' in.
> Sing, cuckoo, sing.
> Death is a-comin' in" -- Tuli Kupferberg
>
>
> _______________________________________________
> kc mailing list
> kc at pm.org
> http://mail.pm.org/mailman/listinfo/kc
>



-- 
Andrew Sterling Hanenkamp
sterling at hanenkamp.com
785.370.4454
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/kc/attachments/20140220/c80aeb0f/attachment.html>


More information about the kc mailing list