You could, of course, just make a better
unpack and turn
it into a module. I would think that adding user defined
types would slow down unpack, which would make this kind of
move very unpopular with people who's business revolves
around packing/unpacking a lot of binary data.
I have to admit that at times I'm also a little frustrated
by the limitations of pack, especially when you don't have
the sort of "stream" methods that you can get, say, in C++,
where you can really go to town.
Applying the TMTOWTDI principle, this would mean that the
"traditional" way would be fast, but limited, and the
"new" way, which is extensible, would be "better" at the
expense of speed.
The function names here are, of course, just for the example:
use Super::Unpack;
my ($foo,$lola,$glarb) = super_unpack ('int int MyType');
my ($foo,$lola,$glarb) = super_unpack (qw [ int int MyType]);
my ($foo,$lola,$glarb) = super_unpack (@spec);
my ($foo,$lola,$glarb) = super_unpack ('network unsigned int','short',
+'MyType');
With a few pre-defined "internal" types, such as 'int',
'long', and 'unsigned short', you could go places really
quickly.
Then this new module could be a Perl6 standard-issue thing,
assuming people were open to this sort of idea.