David Whipp <[EMAIL PROTECTED]> writes:
> Piers Cawley wrote:
>> Maybe we should just say 'sod it' and implement the entire Smalltalk
>> Collection hierarchy and have done with it? Sets, bags, hashes
>> (dictionaries for the Smalltalker), whatever, all have their uses...
>
> I'm not sure if you were being facetious,
I wasn't. I'd love to see something akin to the full Smalltalk
collection hierarchy available with Perl. And I'd love to see them
'blessed' into core Perl so people would *use* them. But I'm not sure
it'll actually happen.
> but I do think all the functionality of these should exist: how many
> times do we have to explain, to newbies, the perl idioms for using
> hashes as sets? Collections boil down to two basic properties:
> ordered/unordered and duplicates/unique. We only have c<%> and c<@>
> available for 4 combinations; and perl uses these to indicate the
> underlying implementation (sans ties), and the type of key. Seems to
> me that we will either end up using c<$> (objects) for most
> collections; or we'll be creative in our use of properties for @ and
> %.
%foo is Ordered
@bar is Set
Hmm... I think I'd rather see
my $foo is Bag = @array.as('Bag');
The idea being that one could treat hashes and arrays as syntactic
vitamins meaning 'Dictionary' (to use the Smalltalk term) and
'OrderedCollection', but all Collections would implement an C<as>
method allowing conversion between the different classes.
Hmm... you know, the more I think about that idea, the more I like
it...
--
Piers
"It is a truth universally acknowledged that a language in
possession of a rich syntax must be in need of a rewrite."
-- Jane Austen?