In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Luke Palmer) wrote:
>David Green writes:
> > In article <[EMAIL PROTECTED]>,
> >  [EMAIL PROTECTED] (Larry Wall) wrote:
> > >Maybe type parameters are just subscripts?  [...]
> > >    my Fight %fight does key{Dog;Cat};
> > I like that.
>
>Yeah, me too.  Except I'm having trouble seeing how key is a role.  It's
>not adding anything into a hash; it's changing it.  Maybe I just don't
>quite grok roles yet.

I definitely don't, but from my approximate understanding, couldn't we 
look at the "Role" of hash as giving you methods for FETCH, STORE, 
EXISTS, etc.?  And "my %hash does key{Str}" is a shorthand for "my %hash 
does Hasherdabery  :key(Str)" (or whatever the correct version would 
be)?    And the mere appearance of a % -- "my %hash" -- is shorterhand 
for telling Perl you want your variable to play the Role of an ordinary 
unaccessorised hash.

This notion was reinforced by Larry's suggesting that you could supply 
code (instead of just a type) to define the keys and values; to me that 
sounds like old-fashioned tying in Role's clothing.  (But that's 
glossing over a lot of details, some of which may actually be important.)

> > >Well, there's always "domain" and "range", if we want to be
> > >mathematical.
>[...]
>What you want here is "domain" and "codomain".  Which leads me to
>believe that you don't want either.

Hm.  Well, if you want to get picky, yes, the "range" should be the set 
of *all* values mapped to from the domain, and it's unlikely that your 
hash contains every possible Str [or whatever] as a value.  But if we're 
being that picky, it's also unlikely that every possible Str is a key, 
either, unless you want to say they map onto 'non-existent' values (not 
to be confused with undefined values).  But a hash isn't a function 
anyway, pickily speaking, because your hash can change (its domain or 
its range), so at best it represents a set of functions.  And what we're 
actually specifying is some sort of metadomain and metarange.  

Or we could just say we don't want to be that picky anyway.  =)


 -David "why we wouldn't want to is beyond me, nit-picking is fun!" Green

Reply via email to