stevan / p5-mop-redux

A(nother) MOP for Perl 5
139 stars 36 forks source link

"DEFINE YOUR API YOU LAZY SOD!" #131

Open kraih opened 11 years ago

kraih commented 11 years ago

While i have to agree with @stevan that the old AUTOLOAD api in Perl is horrible, i believe some implementation of the concept is necessary. If not for new modules, at least for ports of existing ones. The Ruby implementation (method_missing) is not too bad. http://ruby-doc.org/core-2.0.0/BasicObject.html#method-i-method_missing

tobyink commented 11 years ago

Ideally an autoload replacement should, rather than executing the missing method, either return the method as a coderef, or return undef, or die.

Why?

doy commented 11 years ago

Maybe the hook for this should actually be just overriding can?

stevan commented 11 years ago

@doy only if I can have auto-deref back :P

stevan commented 11 years ago

We should look into Class::Std and AUTOMETHOD somewhat, seems similar to what we are talking about (https://metacpan.org/pod/Class::Std#Methods-that-can-be-supplied-by-the-developer)

doy commented 11 years ago

Yeah, although I don't particularly like the magical "call every AUTOMETHOD" thing - there's no reason here why the user can't just return $self->next::method. Especially since with that modification, AUTOMETHOD becomes identical to can(:

stevan commented 11 years ago

@doy - Agreed, we can make forwarding to the parent the responsibility of the user I think that is fair. Although, the "call every $x" is similar to BUILD and DEMOLISH, this would just be AUTOMETHODALL.

doy commented 11 years ago

My main issue is that I don't think the *ALL structure works quite as well for methods that return a value.

stevan commented 11 years ago

I can appreciate that.