Re: Hashes, Stringification, Hashing and Strings

2002-04-16 Thread Aaron Sherman
On Tue, 2002-04-16 at 14:57, Piers Cawley wrote: > Aaron Sherman <[EMAIL PROTECTED]> writes: > > I suspect it would involve: > > > > 1. Copying the key (which might be a reference) on insertion. > > 2. Hashing once, and caching the hash. > > > > This means a minimum of overhead, so it's a good th

Re: Hashes, Stringification, Hashing and Strings

2002-04-16 Thread Piers Cawley
David Wheeler <[EMAIL PROTECTED]> writes: > On 4/16/02 11:57 AM, "Piers Cawley" <[EMAIL PROTECTED]> claimed: > >> Personally I'd like the default hash to return some immutable, unique >> and probably opaque object id (something the like >> 'Foo=HASH(0x81e2a3c)' you get from unoverloaded objects i

Re: Hashes, Stringification, Hashing and Strings

2002-04-16 Thread David Wheeler
On 4/16/02 12:27 PM, "Larry Wall" <[EMAIL PROTECTED]> claimed: > You guys are thinking in terms of a single $obj.hash method. I think > there will be more than one hashish (er...) method available, and each > hash will be able to choose at least whether it wants to hash by $obj._ > (the default)

Re: Hashes, Stringification, Hashing and Strings

2002-04-16 Thread Larry Wall
Piers Cawley writes: : Aaron Sherman <[EMAIL PROTECTED]> writes: : : > On Tue, 2002-04-16 at 14:00, Mike Lambert wrote: : >> Speaking of which, how do we ensure the immutability of keys being put : >> into the hash? I think Perl copied the string, so that: : >> : >> $b = "aa"; : >> $a{$b} = 1; :

Re: Hashes, Stringification, Hashing and Strings

2002-04-16 Thread Steve Fink
On Tue, Apr 16, 2002 at 02:00:33PM -0400, Mike Lambert wrote: > Speaking of which, how do we ensure the immutability of keys being put > into the hash? I think Perl copied the string, so that: RFC266 talks about these issues, though it was just really my take on the problem at the time. http://de

Re: Hashes, Stringification, Hashing and Strings

2002-04-16 Thread David Wheeler
On 4/16/02 11:57 AM, "Piers Cawley" <[EMAIL PROTECTED]> claimed: > Personally I'd like the default hash to return some immutable, unique > and probably opaque object id (something the like > 'Foo=HASH(0x81e2a3c)' you get from unoverloaded objects in Perl5, but > probably not identical). This isn'

Re: Hashes, Stringification, Hashing and Strings

2002-04-16 Thread Piers Cawley
Aaron Sherman <[EMAIL PROTECTED]> writes: > On Tue, 2002-04-16 at 14:00, Mike Lambert wrote: >> Speaking of which, how do we ensure the immutability of keys being put >> into the hash? I think Perl copied the string, so that: >> >> $b = "aa"; >> $a{$b} = 1; >> chop $b; >> print $a{"aa"}; >> >>

Re: Hashes, Stringification, Hashing and Strings

2002-04-16 Thread David Wheeler
On 4/16/02 11:00 AM, "Mike Lambert" <[EMAIL PROTECTED]> claimed: > Speaking of which, how do we ensure the immutability of keys being put > into the hash? I think Perl copied the string, so that: > > $b = "aa"; > $a{$b} = 1; > chop $b; > print $a{"aa"}; > > still works. > > If we start storing

Re: Hashes, Stringification, Hashing and Strings

2002-04-16 Thread Aaron Sherman
On Tue, 2002-04-16 at 14:00, Mike Lambert wrote: > Speaking of which, how do we ensure the immutability of keys being put > into the hash? I think Perl copied the string, so that: > > $b = "aa"; > $a{$b} = 1; > chop $b; > print $a{"aa"}; > > still works. > > If we start storing full thingies in

Re: Hashes, Stringification, Hashing and Strings

2002-04-16 Thread Mike Lambert
:hash() function to return a string. Or has this matter been thought through already? Thanks, Mike Lambert Aaron Sherman wrote: > Date: 16 Apr 2002 12:13:55 -0400 > From: Aaron Sherman <[EMAIL PROTECTED]> > To: Perl6 Language List <[EMAIL PROTECTED]> > Subject: Hashes, Stringi

Re: Hashes, Stringification, Hashing and Strings

2002-04-16 Thread Aaron Sherman
On Tue, 2002-04-16 at 12:21, Larry Wall wrote: > Aaron Sherman writes: > : This allows me to specify separate hashing and stringification methods, > : but retains Perl's original default of combining the two. > > Yes, that's what we intend to do. You can make a man feel so small ;-) Thanks

Re: Hashes, Stringification, Hashing and Strings

2002-04-16 Thread Larry Wall
Aaron Sherman writes: : In this example: : : %hash = ($a=>$b); : : $a can be anything. In fact, since Perl6 promises to retain the original : value of $a, we're rather encouraged to store complex data there. But, : this poses a problem. The key to use for hashing might not ideally be : the

Hashes, Stringification, Hashing and Strings

2002-04-16 Thread Aaron Sherman
In this example: %hash = ($a=>$b); $a can be anything. In fact, since Perl6 promises to retain the original value of $a, we're rather encouraged to store complex data there. But, this poses a problem. The key to use for hashing might not ideally be the string representation. For example