The use of $!attr vs self.attr in core libraries
[email protected] (Aaron Sherman) Thu, 8 Sep 2016 09:55:50 -0400
| Newsgroups | perl.perl6.language |
|---|---|
| Message-ID | <CAN=dS7QngxSFYEcunJsWRgM5nZhjeLnam5Rh=3M8atpz2kJntQ@mail.gmail.com> |
In working with Range a while back, I was frustrated to find that writing a subclass that wanted to override an accessor (e.g. for $.min and $.max) was quite difficult because most methods ignored the accessors and called $!min and $!max or wrote to them directly. If I really wanted to change the semantics, I pretty much had to re-write or at least wrap every existing method, which would make my module nigh unmaintainable. Is this for performance reasons? Would it make sense to try to find a way to make this easier? As a concrete example, here's how "elems" is defined on Range: https://github.com/rakudo/rakudo/blob/32902f25ca753860067a34eb9741aa5524dbe64e/src/core/Range.pm#L96 -- Aaron Sherman, M.: P: 617-440-4332 Google Talk, Email and Google Plus: [email protected] Toolsmith, developer, gamer and life-long student.