Arising out of "Freezing Roles" is a related question.

Suppose I download a module from CPAN with a role I want to use, but it introduces a method that I want that is in conflict with an existing method (say one taken from another CPAN module).

How should the method be aliased to prevent it from causing a conflict at class composition time?

for instance (I think I have the syntax right)

use SQL-DataBase-Module;
use XML-DataBase-Module;
# these are (hypothetical) CPAN modules and contain the roles SQL and XML
# later
class  update  {
does SQL;
#contains the method 'db-write'
does XML;
# also contains the method 'db-write' and a complete match for SQL role method


According to S14, this will cause a conflict detected at compile time. S14 suggests writing a class to rename the conflicting method. Perhaps,

class wrapperXML {
does XML;
method xml-db-write ( @_ ) { self.db-write( @_ ) };

This seems a bit clunky just to rename a method to prevent a conflict.

Is there syntactic sugar for aliasing the conflicting method? Eg. something like
does XML :db-write<xml-db-write>;

Moreover, suppose that the two modules have roles with the same name, eg., suppose XML-Database-Module and SQL-Database both define a role 'Writable'. How could these one (or both) of these roles be aliased?


Reply via email to