RE: pseudo-hashes? was: Data structure question

2001-01-23 Thread John Hughes
And indeed, they ought to die. Or be reimplemented. Or something, but quite simply, don't use them. They'll break, they won't dwim, and chances are they won't play nice with future/past versions of Perl. Forget they even exist. Details? I'm using them with no problems in 5.005_03 (the real

RE: pseudo-hashes? was: Data structure question

2001-01-23 Thread John Hughes
I had already reached the same conclusion after I saw that everyone would have to remember to say "my Dog $spot;" every time or the whole thing falls apart. Falls apart? How? If you want something reasonably close, you could do what a lot of the Template Toolkit code does and use arrays

RE: pseudo-hashes? was: Data structure question

2001-01-23 Thread Matt Sergeant
On Tue, 23 Jan 2001, John Hughes wrote: And indeed, they ought to die. Or be reimplemented. Or something, but quite simply, don't use them. They'll break, they won't dwim, and chances are they won't play nice with future/past versions of Perl. Forget they even exist. Details? I'm

RE: pseudo-hashes? was: Data structure question

2001-01-23 Thread Matt Sergeant
On Tue, 23 Jan 2001, John Hughes wrote: I had already reached the same conclusion after I saw that everyone would have to remember to say "my Dog $spot;" every time or the whole thing falls apart. Falls apart? How? Because you miss one out and its a very difficult to find bug in your

RE: pseudo-hashes? was: Data structure question

2001-01-23 Thread John Hughes
(exists doesn't work). Neither does delete. Ok. But what should it do? What does it do for an array? And overloading doesn't really work properly. Details? And reloading modules with phashes doesn't work right. I steer clear of reloading, almost anything screws up. And sub-hashes

RE: pseudo-hashes? was: Data structure question

2001-01-23 Thread Matt Sergeant
On Tue, 23 Jan 2001, John Hughes wrote: (exists doesn't work). Neither does delete. Ok. But what should it do? What does it do for an array? But we're talking about hashes! At the very least it should make it so that exists() returns false. And overloading doesn't really work

RE: pseudo-hashes? was: Data structure question

2001-01-23 Thread Robin Berjon
At 11:36 23/01/2001 +0100, John Hughes wrote: Neither does delete. Ok. But what should it do? What does it do for an array? perldoc -f delete "In the case of an array, if the array elements happen to be at the end, the size of the array will shrink to the highest element that tests true for

Re: pseudo-hashes? was: Data structure question

2001-01-23 Thread DeWitt Clinton
On Tue, Jan 23, 2001 at 10:06:13AM +, Matt Sergeant wrote: The only gain might be in a large DOM tree where there may be thousands of objects. But then you're really better off using an array based class instead (as I found out). This is getting a bit off-topic, but I'm empirically found

RE: pseudo-hashes? was: Data structure question

2001-01-23 Thread Matt Sergeant
On Tue, 23 Jan 2001, Robin Berjon wrote: At 11:36 23/01/2001 +0100, John Hughes wrote: Neither does delete. Ok. But what should it do? What does it do for an array? perldoc -f delete "In the case of an array, if the array elements happen to be at the end, the size of the array will

RE: pseudo-hashes? was: Data structure question

2001-01-23 Thread Robin Berjon
At 12:50 23/01/2001 +, Matt Sergeant wrote: Thats only 5.6+ though. So its only useful for internal applications (if at all). True, but we've been using 5.6 (built from AS source) in production for quite a while now very happily. Also, I'm seeing more and more customers having it or ready to

RE: pseudo-hashes? was: Data structure question

2001-01-23 Thread Perrin Harkins
On Tue, 23 Jan 2001, John Hughes wrote: I had already reached the same conclusion after I saw that everyone would have to remember to say "my Dog $spot;" every time or the whole thing falls apart. Falls apart? How? If you forget the "Dog" part somewhere, it's slower than a normal

pseudo-hashes? was: Data structure question

2001-01-22 Thread Tom_Roche
Until reading Conway's "Object Oriented Perl" http://www.manning.com/Conway/ (section 4.3, pp 126-135) I hadn't heard about pseudo-hashes. I now desire a data structure with non-numeric keys, definable iteration order, no autovivification, and happy syntax. (And, of course, fast-n-small :-)

Re: pseudo-hashes? was: Data structure question

2001-01-22 Thread Matt Sergeant
On Mon, 22 Jan 2001, [EMAIL PROTECTED] wrote: Well you've already seen I'm a detractor :-) * Is anyone now using (under mod_perl) something they consider to be superior but with similar functionality and interface? Yes, a class which is a blessed array. -- Matt/ /||** Director

Re: pseudo-hashes? was: Data structure question

2001-01-22 Thread Robin Berjon
At 18:05 22/01/2001 -0500, [EMAIL PROTECTED] wrote: the Perl6 RPC "Pseudo-hashes must die!" and And indeed, they ought to die. Or be reimplemented. Or something, but quite simply, don't use them. They'll break, they won't dwim, and chances are they won't play nice with future/past versions of

Re: pseudo-hashes? was: Data structure question

2001-01-22 Thread Perrin Harkins
On Mon, 22 Jan 2001 [EMAIL PROTECTED] wrote: (section 4.3, pp 126-135) I hadn't heard about pseudo-hashes. I now desire a data structure with non-numeric keys, definable iteration order, no autovivification, and happy syntax. (And, of course, fast-n-small :-) Having Conway's blessing is nice

Re: pseudo-hashes? was: Data structure question

2001-01-22 Thread Ken Williams
[EMAIL PROTECTED] (Perrin Harkins) wrote: On Mon, 22 Jan 2001 [EMAIL PROTECTED] wrote: (section 4.3, pp 126-135) I hadn't heard about pseudo-hashes. I now desire a data structure with non-numeric keys, definable iteration order, no autovivification, and happy syntax. (And, of course,

Re: Data structure question

2000-06-08 Thread Stephen Zander
"Drew" == Drew Taylor [EMAIL PROTECTED] writes: Drew I would like to return a single data structure, but order IS Drew important (hence the current setup). I was thinking of using Drew an array, where each element is a hash reference. So I would Drew return something like this:

Re: Data structure question

2000-06-08 Thread Matt Sergeant
On 8 Jun 2000, Stephen Zander wrote: "Drew" == Drew Taylor [EMAIL PROTECTED] writes: Drew I would like to return a single data structure, but order IS Drew important (hence the current setup). I was thinking of using Drew an array, where each element is a hash reference. So I

Data structure question

2000-06-06 Thread Drew Taylor
Hello, This doesn't directly relate to mod_perl, but I'd like to make this as memory efficient as possible since it runs under mod_perl. :-) I have a question about data structures. Currently, I am doing SQL queries and returning an array ref and a hash ref. The array is to preserve order, and

Re: Data structure question

2000-06-06 Thread Ken Y. Clark
On Tue, 6 Jun 2000, Drew Taylor wrote: I have a question about data structures. Currently, I am doing SQL queries and returning an array ref and a hash ref. The array is to preserve order, and the hash contains various bits of data about that not to be dense, but can't you just issue an

Re: Data structure question

2000-06-06 Thread Gunther Birznieks
Using tied hashes, you could conceivably make your own ordered hash class and use that as the data structure you return. You'd still basically have two data structures (for performance) but the fact that it is two data structures would be hidden behind the tied hash which would be programmed

Re: Data structure question

2000-06-06 Thread Eric Cholet
Using tied hashes, you could conceivably make your own ordered hash class and use that as the data structure you return. You'd still basically have two data structures (for performance) but the fact that it is two data structures would be hidden behind the tied hash which would be programmed

Re: Data structure question

2000-06-06 Thread Ken Miller
At 12:39 PM 6/6/00 -0400, Drew Taylor wrote: Hello, This doesn't directly relate to mod_perl, but I'd like to make this as memory efficient as possible since it runs under mod_perl. :-) I have a question about data structures. Currently, I am doing SQL queries and returning an array ref and a

Re: Data structure question

2000-06-06 Thread Stas Bekman
On Tue, 6 Jun 2000, Eric Cholet wrote: Using tied hashes, you could conceivably make your own ordered hash class and use that as the data structure you return. You'd still basically have two data structures (for performance) but the fact that it is two data structures would be hidden

Re: Data structure question

2000-06-06 Thread Drew Taylor
"Ken Y. Clark" wrote: On Tue, 6 Jun 2000, Drew Taylor wrote: I have a question about data structures. Currently, I am doing SQL queries and returning an array ref and a hash ref. The array is to preserve order, and the hash contains various bits of data about that not to be dense,

Re: Data structure question

2000-06-06 Thread Drew Taylor
Gunther Birznieks wrote: Using tied hashes, you could conceivably make your own ordered hash class and use that as the data structure you return. You'd still basically have two data structures (for performance) but the fact that it is two data structures would be hidden behind the tied hash

Re: Data structure question

2000-06-06 Thread Drew Taylor
Eric Cholet wrote: Using tied hashes, you could conceivably make your own ordered hash class and use that as the data structure you return. You'd still basically have two data structures (for performance) but the fact that it is two data structures would be hidden behind the tied hash

Re: Data structure question

2000-06-06 Thread Nick Tonkin
On Tue, 6 Jun 2000, Drew Taylor wrote: "Ken Y. Clark" wrote: On Tue, 6 Jun 2000, Drew Taylor wrote: I have a question about data structures. Currently, I am doing SQL queries and returning an array ref and a hash ref. The array is to preserve order, and the hash contains

Re: Data structure question

2000-06-06 Thread Drew Taylor
Ken Miller wrote: Well, if the keys are unique, you could just return a hashref, and then access it using sorted keys: foreach( sort keys %$HR ) { ## insert useful stuff here } If only I could just use sort. :-) The order could be completely arbitrary, based on search parameters,

RE: Data structure question

2000-06-06 Thread Jerrad Pierce
. | _| | \|| _.-~-._.-~-._.-~-._@" _|\_|___|___| -Original Message- From: Drew Taylor [mailto:[EMAIL PROTECTED]] Sent: Tuesday, June 06, 2000 14:56 To: Ken Miller Cc: modperl Subject: Re: Data structure question Ken Miller wrote: Well, if the keys are unique, you could just r

Re: Data structure question

2000-06-06 Thread Drew Taylor
Stas Bekman wrote: and in perl5.6 it's called pseudohash (well it was known before but is supported in 5.6) http://www.perl.com/pub/doc/manual/html/pod/perldelta.html#Pseudo_hashes_are_supported I know about pseudohashes - thanks to Damien again! :-). They look very cool, but to be honest

Re: Data structure question

2000-06-06 Thread Drew Taylor
Jerrad Pierce wrote: you can use sort, of the values are hashes or indexes: foreach ( sort { $a-{name} cmp $b-{name} keys %hash ) or foreach ( sort { $a-[0] cmp $b-[0] keys %hash ) In this case I can't use sort since the order is completely arbitrary, based on the SQL issued. Hence the

Re: Data structure question

2000-06-06 Thread Perrin Harkins
On Tue, 6 Jun 2000, Drew Taylor wrote: I know about tied hashes - Thanks Damien for your excellent book! - but there is a performance penalty. How big is this penalty? Is it worth using tied hashes? Versus an array of hash refs? They're a lot slower than normal data structures, or even normal

Re: Data structure question

2000-06-06 Thread Stas Bekman
On Tue, 6 Jun 2000, Perrin Harkins wrote: On Tue, 6 Jun 2000, Drew Taylor wrote: I know about tied hashes - Thanks Damien for your excellent book! - but there is a performance penalty. How big is this penalty? Is it worth using tied hashes? Versus an array of hash refs? They're a lot

Re: Data structure question

2000-06-06 Thread darren chamberlain
Hi Drew, How about writing a custom sort routine, based on the order you would be using in the array, and returning that as a code ref? Sorting the hash would be as simple as: Common.pm: sub

Re: Data structure question

2000-06-06 Thread Drew Taylor
darren chamberlain wrote: Hi Drew, How about writing a custom sort routine, based on the order you would be using in the array, and returning that as a code ref? Sorting the hash would be as simple as: In this case, it's overkill: the DB has already put the data together in the order I

Re: Data structure question

2000-06-06 Thread Drew Taylor
Stas Bekman wrote: On Tue, 6 Jun 2000, Perrin Harkins wrote: On Tue, 6 Jun 2000, Drew Taylor wrote: I know about tied hashes - Thanks Damien for your excellent book! - but there is a performance penalty. How big is this penalty? Is it worth using tied hashes? Versus an array of