Skip Menu |

This queue is for tickets about the Method-Signatures CPAN distribution.

Report information
The Basics
Id: 43943
Status: rejected
Priority: 0/
Queue: Method-Signatures

People
Owner: Nobody in particular
Requestors: ovid [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: Mark methods as overridden
I'd like to optionally be able to specify an 'override' attribute for methods: package Soldier; use Method::Signatures 'override'; use parent 'Some::Class'; method new (%args) { return bless {%args}, $self; } method name : override { ... } # fails if there is no parent method method rank { ... } # fails if it overrides I realize that probably isn't the best way to go about this, but the background is at: http://stackoverflow.com/questions/623680/detecting-overridden-methods-in-perl Basically, Perl silently overrides parent methods (many OO languages do). C++ sort of works around this by forcing someone to declare a method as virtual if it's to be overrideable, but that means when you're in a subclass you can't just glance at a method and know it's overriding a parent method. I think the notation should be in the parent method. MRO::Compat creates an mro::get_pkg_gen method to let you know if a packages method cache has been invalidated. Also, this is problematic if a parent class delays installing a method in a symbol table. It's the nature of dynamic languages that this is fraught with error, but twice in the past week I've been bitten by code which silently overrode a method. This can be very hard to debug (and should there be a mechanism to allow this code to be a no-op in a production environment?) Feel free to mark this as rejected. Just thought I would throw it out there. Cheers, Ovid
Ovid, Show quoted text
> I'd like to optionally be able to specify an 'override' attribute for > methods: > > package Soldier; > > use Method::Signatures 'override'; > use parent 'Some::Class'; > > method new (%args) { > return bless {%args}, $self; > } > > method name : override { ... } # fails if there is no parent > method > method rank { ... } # fails if it overrides
I've been staring at this RT ticket for about a year now, and I think I've finally formed an opinion on it. :-) I think Method::Signatures is not really the right place to do this. Outside of Moose, it strikes me as being tough to do efficiently, and, with Moose, it seems it could be done using metaclass fiddling or some equivalent mechanism. I'm going to reject it for now; if you want to reopen a discussion on it, I'd recommend opening a GitHub issue and I'll see if I can get more eyeballs on it. Thanx.