Daniel Ruoso daniel-at-ruoso.com |Perl 6| wrote:
Especially when the fit does not have to be perfect. Part of my
(unfinished overall) design is to have a way to say "close enough". It
will line up the stuff that fits, and put runtime checks around the
stuff that doesn't. I use the keyword 'shoehorn' for this forced
Qua, 2008-04-30 às 08:56 -0700, Ovid escreveu:
I had initially thought this, but think about the case where someone
wants to rewrite something to be compliant to another interface. If I
pass a CGI::Simple object to a method expecting a CGI object, there's
an excellent chance that it will *just work*, even though there's no
relation between the two. In this case, a role really doesn't work.
This makes me think that 'realises' has a considerably more common usage
than I thought... Every time you implement something like CGI::Simple,
you would like to say 'CGI::Simple realises CGI'.
Of course that, in an ideal OO world, CGI would be an abstract role that
both the default CGI implementation and CGI::Simple would 'do'. But that
seems to javaish to me (read that as something I hate;), and having how
to 'lie' about who you are seems more like a Perl thing to do...
So you can shoehorn a CGI::Simple into a CGI to call code that was
written to expect strict subtyping. It will work just like non-typed
message dispatch, only let you use optimized dispatch tables and
document the intent and have it tell you (if you care) where the problem
areas will be.