Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • class Car { # this is Perl 6 code
        my $cars-produced = 0;
        has $.cars-produced := $cars-produced;

        submethod BUILD() {
            ++$cars-produced;
        }
    }

    So you have a shared counter, an alias of it per instance (which seems redundant, but makes it work*... perhaps by some means one could persuade the compiler to compile it away, as it's constant as a reference), and accessors for inheriting.

    Rakudo doesn't like the 'has $.x := $y' construct (ye

    • I was reminded by TimToady that something very much like this is already possible class Car { my $.cars-produced = 0; #`[...] }. It's spec'd and everything, in S12:731. Hope that helps. :)