develooper Front page | perl.perl6.language | Postings from May 2008

Re: First look: Advanced Polymorphism whitepaper

Thread Previous | Thread Next
From:
John M. Dlugosz
Date:
May 2, 2008 15:55
Subject:
Re: First look: Advanced Polymorphism whitepaper
Andy_Bach-at-wiwb.uscourts.gov |Perl 6| wrote:
> in. Er, so would:
> my CGI::Simple $x .= new;
> my $y = CGI::Simple.new;
>
> mean that:
> $x <whatever the compare class operater is> $y
>
> is not true?  Or would there be a way to tell them apart, on a class (?) 
> level.
>
>   

The actual dynamic type at run time of the values in $x and $y are both 
CGI::Simple.

The static compile-time type of $y is Any.

$x.nosuchmethod;

will give a compile-time error if nosuchmethod is not declared as part 
of CGI::Simple.

$y.nosuchmethod;

will look it up when the attempt is made, and only then fail.  (Or 
succeed if something funny is going on and it exists =now= but wasn't 
declared originally.  There are a few documented ways to be funny already.)





Thread Previous | Thread Next


Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About