Me wrote: > > > The problem I see with inheriting subblocks such as > > FIRST/LAST/etc, is that they are tied in with the logic > > ... of their enclosing block... > > Surely this is an argument *for* it being pretty odd > *not* to inherit them. > > Let's say you add a LAST block to a method. In the > LAST block you write clean up code that frees some > resources. If you inherit from that method, and do not > inherit the LAST block, then you've got a leak. This is > obviously a mild example.
Methinks (that's me, not you) that if me thinks (that's you, not me) that my argument is an argument *for* it being pretty odd *not* to inherit them, that there is an assumption by me or me (that's one or the other of us) that is clearly wrong about the way inheritance of methods (should) work. In my mind, the idea of inheriting a method is that the subclass and the superclass have a common subroutine that is invoked whether the message is sent to the subclass or to the superclass. In Perl6 terms, that subroutine may include PRE/POST blocks, FIRST/LAST/NEXT/CATCH/UNDO/KEEP blocks, embedded closures and other statements, whatever the implementation needs to be to get the job done correctly. The whole she-bang subroutine implementation comes along for the inheritance ride. The idea that has been mentioned of having PRE and POST blocks be inherited is a slightly different concept... in that case, the method itself is NOT being inherited, and NONE of the code of the method in the superclass is used by the subclass... Except the PRE and POST conditions, as implemented by the PRE and POST blocks. They would get inherited to allow the design by contract invariants required by the superclass to be enforced in spite of subclassing. This separate type of inheritance is another reason that perhaps the PRE and POST blocks should not be included within the block of the subroutine that implements a method, but perchance should be defined outside of them... perhaps as properties of the method definition? I would be extremely doubtful of Larry's lucidity if I thought that he was suggesting that none of the FIRST/LAST/NEXT/CATCH/UNDO/KEEP blocks were included with an inherited method, but I don't think that. Such blocks are an inherent part of the implementation of the method, not an inherit part of subclassing. What do you think, me? > --me -- Glenn ===== Due to the current economic situation, the light at the end of the tunnel will be turned off until further notice.