develooper Front page | perl.perl5.porters | Postings from May 2000

Re: overloading = [a solution]

Thread Previous | Thread Next
From:
Damian Conway
Date:
May 5, 2000 15:58
Subject:
Re: overloading = [a solution]
Message ID:
200005052258.IAA04978@indy05.csse.monash.edu.au
   > How is it different from simple tie()ing?

For most folks outside P5P tie()ing isn't "simple".
In any case this *is* tie()ing, just packaged much more conveniently.


   > See also
   > 
   >   my Dog $snoopy;
   > 
   > and PREPARE method.

This is orthogonal to typed lexicals.
In fact, there's no reason you couldn't:

	classify my Dog $snoopy => 'Pilot';

Typed lexicals aren't enough on their own. Specifically, they won't stop
type-incompatible assignments that introduce subtle bugs:

	my Dog $snoopy;

	$snoopy = Alligator->new();

	$snoopy->pat();		# unexpected behaviour ;-)

	$snoopy->{age}++;	# maybe *very* unexpected behaviour
				# E.g:
				#
				#	package Dog;
				#	use fields qw(name age sex breed);
				#
				#	package Alligator;
				#	use fields qw(age size weight ID);


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