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

Re: overloading = [a solution]

Thread Previous | Thread Next
Damian Conway
May 5, 2000 15:58
Re: overloading = [a solution]
Message ID:
   > 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);


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About