in reply to Class::Trait to the CPAN?
This is the definition given in the C++ Standard:
17.1.18 traits class [defns.traits]
a class that encapsulates a set of types and functions necessary for template classes and template functions to manipulate objects of types for which they are instantiated. Traits classes defined in clauses 21, 22 and 27 are chararacter traits, which provide the character handling support needed by the string and iostream classes.-- ISO/IEC 14882:1998(E)
In Standard C++ these are used to package the basic character operations for equality, dictionary ordering, string length, searching, movement and copying. There, they are characterized by the requirements that they present a unified interface and that each character class provides a concrete implementation of that interface. They sound very like the set of conditions you cite.
Under Perl's looser type regimen, generic (template) programming is usually regarded as automatic. An instance class's methods are assumed to provide the needed interface, and it is up to the programmer to make sure they automatically do ;-)
It seems to me that there are two fairly natural implementations available in Perl 5.
One less-known aspect of C++ traits is that their methods do not throw. Is some no-error convention appropriate for Perl traits?
After Compline,
Zaxo
|
|---|