On Wed, Mar 30, 2005 at 09:40:26AM -0700, Luke Palmer wrote:
: There _is_ a way to do it, actually, but we need to really screw around
: with what kinds of things are inferred.  In the case:
: 
:     my $a;
:     $a.m(1);
: 
: We assign the type "objects with an 'm' method that can take a single
: integer" to $a.  This is a category of objects that spans many classes,
: and does not fit into a nice little tree.

I think it's perfectly fine for the compiler to make use of whatever
information it has.  The trick is to never make any unwarranted
assumptions, such as "Nobody will ever add another class with an 'm'
method."  It can assume that only if you explicitly tell it to, and
if nobody has jimmied any classes to remain open and/or non-final.
Otherwise you have to at least be prepared to recalculate the
effective meaning of your 'm' type, and know when that recalculation
is necessary.  Even if classes are open and non-final, you can
at least cache information that is temporarily true, and make good
use of it.  Perl 5 certainly takes that approach in spots.  Perl 5
doesn't do a good job of localizing the damage, however.  If you
monkey around with your classes, it basically throws away all the
cached data by incrementing a generation count.

: I think that before we take on such an idea, we should look for
: research about this kind of type inference.

As long as "we" includes "you", that's fine by "me".  :-)

Larry

Reply via email to