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
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
How about this? (Score:1)
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 (yet?), nor other variations moving the bind into the BUILD, but std parses it fine, at least. So when I say 'makes it work', I mean 'in Perl 6, in theory, in my head'.
Reply to This
Re: (Score:1)
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.Re: (Score:1)
Oh, yes, that's exactly the thing.
I think
has $.x := $ywould have its uses, too; i'll poke around (in spec, code, #perl6) to see what might block/enable it.