in reply to Re: Using perlclass 'methods'
in thread Using perlclass 'methods'
This is not the correct explanation. Deparse helps:
unexpected OP_METHSTART at /usr/share/perl5/B/Deparse.pm line 1674. unexpected OP_METHSTART at /usr/share/perl5/B/Deparse.pm line 1674. sub BEGIN { require v5.38.0; () } use warnings; use strict; no feature ':all'; use feature ':5.38'; use experimental ('class'); BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x5 +5\x55\x55\x55\x55\x55\x55\x55\x55\x51\x55"} use feature 'class'; { package Gear; ; sub ratio : method { XXX; return $chainring / $cog; } sub gear_inches : method { XXX; return ratio(*$rim + $tire * 2); } } say 'Gear'->new('chainring', 52, 'cog', 11, 'rim', 26, 'tire', 1.5)->g +ear_inches;
(I had to modify the code a bit because I don't have 5.40)
So it takes everything that comes after the method name as the argument, so the * is interpreted as a glob dereference.
Note that B::Deparse also struggles with the new class feature.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Using perlclass 'methods'
by haj (Vicar) on Jul 18, 2024 at 10:20 UTC |
In Section
Seekers of Perl Wisdom