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

Re: overloading = [a solution]

Thread Previous | Thread Next
From:
Damian Conway
Date:
May 6, 2000 22:02
Subject:
Re: overloading = [a solution]
Message ID:
200005070502.PAA11046@indy05.csse.monash.edu.au
   
   > But this goes closer to the CORE now than to a module.
   > 
   >   my Dog $foo :confine;

This is an excellent point. I will extend the module so that it exports a 
MODIFY_SCALAR_ATTRIBUTES to UNIVERSAL (and perhaps a PREPARE to caller()).
Then users have a plethora of choice:

	use Class::TypedVars;		# Proposed new name for Class::ifiedVars

# then:
	classify $foo => 'Dog';		# Dam-ian interface
# or:
	type DogsOnly => 'Dog';		# Dam-ian typed interface
	DogsOnly ($foo);
# or:
	my Dog $foo : constrain;	# Ily-ian attributed interface
# or:
	tie $foo, 'Class::TypedVars';	# Ily-ian "killer" interface :-)
# or: 
	package Dog;
	use Class::TypedVars;

	package main;
	my Dog $foo;			# Stealth interface


That should be enough choice of APIs for anyone ;-)

Note, that the attribute/PREPARE-based interfaces (which I do like) are
insufficient in the general case, since they doesn't cater for constraining
assignments to package vars, array elements, or hash entries.

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