Re: specifying the key Type for a Hash

2004-12-10 Thread Michele Dondi
On Mon, 6 Dec 2004, Luke Palmer wrote: Well, there's always "domain" and "range", if we want to be mathematical. [snip] What you want here is "domain" and "codomain". Which leads me to believe that you don't want either. For the record, in most connections "range" would be just as good. Indeed "

Re: specifying the key Type for a Hash

2004-12-07 Thread Brent 'Dax' Royal-Gordon
Matt Diephouse <[EMAIL PROTECTED]> wrote: > On Tue, 7 Dec 2004 00:39:08 -0800, Brent 'Dax' Royal-Gordon > > my Patient @byid[Int $id] { > > select_patients("SELECT * FROM patients WHERE patientid = ?", > > $id)[0]; > > } > > multi my Patient %byname{String $last} { > >

Re: specifying the key Type for a Hash

2004-12-07 Thread Matt Diephouse
On Tue, 7 Dec 2004 00:39:08 -0800, Brent 'Dax' Royal-Gordon <[EMAIL PROTECTED]> wrote: > Larry Wall <[EMAIL PROTECTED]> wrote: > > Also says maybe you could attach a block to a hash or array to > > define what subscripting does. Hmm. > > That's...wow. > > class Patient { > my DBI::Connection

Re: specifying the key Type for a Hash

2004-12-07 Thread David Green
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

Re: specifying the key Type for a Hash

2004-12-07 Thread Brent 'Dax' Royal-Gordon
Larry Wall <[EMAIL PROTECTED]> wrote: > Also says maybe you could attach a block to a hash or array to > define what subscripting does. Hmm. That's...wow. class Patient { my DBI::Connection $db; my Patient @byid[Int $id] { select_patients("SELECT * FROM patients WHERE patientid

Re: specifying the key Type for a Hash

2004-12-06 Thread Larry Wall
On Mon, Dec 06, 2004 at 03:11:15AM -0700, David Green wrote: [snip] : I like that. [snip] : I like that even better. [snip] : I'm happy with those too (perhaps because I do want to be a bit : mathematical). [snip] : "is FAT"? Yeah, that works for me too. =) [snip] : I would take that as an abbre

Re: specifying the key Type for a Hash

2004-12-06 Thread Abhijit Mahabal
On Mon, 6 Dec 2004, Larry Wall wrote: Hmm. Also says maybe you could attach a block to a hash or array to define what subscripting does. Hmm. That's tantalizing. Did you have something like this in mind: # Count number of accesses to each key our %counter_hash; my %hash is subscripted -> $subs

Re: specifying the key Type for a Hash

2004-12-06 Thread Larry Wall
On Mon, Dec 06, 2004 at 05:43:16AM +, Nigel Sandever wrote: : I probably missed teh comprehensive dismissal thread, but why not 'type'? : : my %pet is Hash[:type(Str) :returns(Cat)]; Well, "type" is just a little off in a couple of ways. On the one hand, it's not specific enough, insof

Re: specifying the key Type for a Hash

2004-12-06 Thread Luke Palmer
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 anythi

Re: specifying the key Type for a Hash

2004-12-06 Thread David Green
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Smylers) wrote: >No! Avoid synonyms. They're initially tempting, because then everybody >gets to pick the one he/she wants to use, but then it turns out you need >to learn all of them so as to read other people's code, and that's worse >than no

Re: specifying the key Type for a Hash

2004-12-06 Thread David Green
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. >But if English-like is the criterion that'd still read better as >my Fight %fight has key{Dog;Cat}; I like that even

Re: specifying the key Type for a Hash

2004-12-06 Thread Nigel Sandever
On Sat, 04 Dec 2004 08:01:46 -0700, [EMAIL PROTECTED] (David Green) wrote: > In article <[EMAIL PROTECTED]>, > [EMAIL PROTECTED] (Larry Wall) wrote: > >S9 talk about it. We current have things like: > >my Cat %pet is shape(Str); > >and parameters to types are in square brackets, so it's more

Re: specifying the key Type for a Hash

2004-12-05 Thread Smylers
Larry Wall writes: > But pretty much every time I've introduced synonyms into Perl I've > come to regret it. But hey, if I introduce *different* synonyms this > time, does that count as making a new mistake? No! Avoid synonyms. They're initially tempting, because then everybody gets to pick th

Re: specifying the key Type for a Hash

2004-12-04 Thread David Wheeler
On Dec 4, 2004, at 10:57 AM, Larry Wall wrote: Well, I just put "is shape" because that's what the PDLers settled on, but as far as I'm concerned linguistically, it could just be "is dim". That would settle the "make-it-like-English" question by making it not at all like English. On the aesthetic h

Re: specifying the key Type for a Hash

2004-12-04 Thread Larry Wall
On Sat, Dec 04, 2004 at 08:01:46AM -0700, David Green wrote: : In article <[EMAIL PROTECTED]>, : [EMAIL PROTECTED] (Larry Wall) wrote: : >S9 talk about it. We current have things like: : >my Cat %pet is shape(Str); : >and parameters to types are in square brackets, so it's more like: : >m

Re: specifying the key Type for a Hash

2004-12-04 Thread David Green
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Larry Wall) wrote: >S9 talk about it. We current have things like: >my Cat %pet is shape(Str); >and parameters to types are in square brackets, so it's more like: >my %pet is Hash[:shape(Str) :returns(Cat)]; I still prefer "shaped", for

Re: specifying the key Type for a Hash

2004-12-03 Thread Abhijit Mahabal
On Fri, 3 Dec 2004, Larry Wall wrote: : None of the synopses have anything like this. S6 talks about the : types of values, but not keys. Oversight, or is this syntax dead? S9 talk about it. Oops. Sorry. So it was oversight after all :) --abhijit Abhijit Mahabal http://www.cs.indiana.edu/~amah

Re: specifying the key Type for a Hash

2004-12-03 Thread Larry Wall
On Fri, Dec 03, 2004 at 05:23:56PM -0500, Abhijit Mahabal wrote: : A6 included examples of syntax for specifying the type of the key for a : hash: : : my %pet is Hash(keytype => Str, returns => Cat) : : None of the synopses have anything like this. S6 talks about the : types of values, but not

specifying the key Type for a Hash

2004-12-03 Thread Abhijit Mahabal
A6 included examples of syntax for specifying the type of the key for a hash: my %pet is Hash(keytype => Str, returns => Cat) None of the synopses have anything like this. S6 talks about the types of values, but not keys. Oversight, or is this syntax dead? --abhijit Abhijit Mahabal http://