NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
Type Safety with Roles (Score:1)
Also, unlike Java's interfaces, role names and type names share a namespace. That's all of the goodness of allomorphic type checking in signatures.
Re:Type Safety with Roles (Score:2)
I thought I had posted a response, but apparently I had not :(
First, can you give a clear definition of "allomorphism"? Try as I might, I can't quite understand it. It seems like allomorphism [c2.com] is similar to polymorphism, except you can override behavior on an instance level instead of a class level and all that's relevant is that the interface is consistent. Is that correct? I think not because it's too simple.
Also, I'm not sure what you mean by "role names and type names share a namespace." What be
Class layout (Score:1)
Omaha Perl Mongers [pm.org]
Re:Class layout (Score:2)
With all due respect, I think you've inadvertently illustrated my point. Let's stick with Perl 5 and assume that delegation is the key to performing profession-specific behavior, but we won't use delegation yet. We'll assume four races, human, elf, dwarf and halfling. We'll also assume four professions, fighter, thief, magician and cleric. With the Character and Profession abstract base classes, we have a grand total of ten classes, each which encapsulates the basic attributes of what they're trying to m
Re:Class layout (Score:1)
2) If the class structure *is* needed for some reaso
Omaha Perl Mongers [pm.org]
Re:Class layout (Score:2)
Those are valid questions. The truth is, you never need objects to accomplish any programming problem. I chose objects for this illustration primarily because characters are really bundles of data with behaviors attached to them. This, of course, is one way objects are defined.
As for how mixins solve the problem more elegantly, you might want to read a virtually identical node on Perlmonks [perlmonks.org]. In light of the responses, I back off a bit from asserting the utility of mixins once it became clear that they'
Decorator Pattern? (Score:1)
http://www.oreilly.com/catalog/hfdesignpat/chapter/index.html [oreilly.com]
j
Omaha Perl Mongers [pm.org]