develooper Front page | perl.perl6.language | Postings from April 2003

Re: HELP! Type Casting [was: Type Coercions]

Thread Previous | Thread Next
From:
Damian Conway
Date:
April 17, 2003 17:24
Subject:
Re: HELP! Type Casting [was: Type Coercions]
Message ID:
3E9F45B7.3060506@conway.org
Luke Palmer wrote:

> Huh?  You don't have to check it explicitly.  Cat doesn't support the
> bark() method, so it can't be used as a Dog.  And the type system will
> see that.  End of story.

There are, however, problems with an interface approach. For example:

	class Dog {
	   method breathe()      {...}
	   method feed()         {...}
	   method grow()         {...}
	   method bark()         {...}
	   method reproduce()    {...}
	   method die()          {...}
	}

	class Oak {
	   method breathe()      {...}
	   method feed()         {...}
	   method grow()         {...}
	   method bark()         {...}
	   method reproduce()    {...}
	   method die()          {...}
	}

	
	my Oak $tree = Dog.new();
	my Dog $spot = Oak.new();

:-(

Damian


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About