Re: Perl Critic and (honest) hash references

2009-03-19 Thread Nicholas Clark
On Mon, Mar 02, 2009 at 11:15:53PM -0800, Joshua ben Jore wrote: On Mon, Mar 2, 2009 at 12:22 PM, Nicholas Clark n...@ccl4.org wrote: On Mon, Mar 02, 2009 at 10:23:38AM -0800, Bill Ward wrote: Personally I always use hashes for objects.  Hashes are pretty fast in Perl, especially when

Re: Perl Critic and (honest) hash references

2009-03-03 Thread David Cantrell
On Mon, Mar 02, 2009 at 08:22:24PM +, Nicholas Clark wrote: Hash lookup should be O(1), independent of number of keys. Of course, a hash with more keys uses more memory, but so does an array with more elements. But that's a bigger value of 1 from that required for an array lookup. --

Re: Perl Critic and (honest) hash references

2009-03-03 Thread Jonathan Yu
This is addressed to the participants of this conversation in general: I think getting to discussions of O(1) or whatever is a bit much for a language like Perl. It's not designed for speed, though speed is certainly nice to have. It's also got a fantastic (well, it's got a bit of a learning

Re: Perl Critic and (honest) hash references

2009-03-03 Thread Jonathan Yu
Jonathan: On Tue, Mar 3, 2009 at 1:16 PM, Jonathan Rockway j...@jrock.us wrote: * On Tue, Mar 03 2009, Jonathan Yu wrote: Choosing array-based parameterization instead of hashes seems to be a bad idea to me, because you could potentially end up with lots of cases of sparse arrays. ... I

Re: Perl Critic and (honest) hash references

2009-03-02 Thread Johan Vromans
David Cantrell da...@cantrell.org.uk writes: Tie::Hash::Vivify is useful for detecting this: my $hashref = Tie::Hash::Vivify-new(sub { confess(No auto-vivifying (did you mis-spell something?)\n.Dumper(\...@_)) }); What's wrong with lock_keys from Hash::Util? -- Johan

Re: Perl Critic and (honest) hash references

2009-03-02 Thread David Cantrell
On Mon, Mar 02, 2009 at 09:17:22AM +0100, Johan Vromans wrote: David Cantrell da...@cantrell.org.uk writes: Tie::Hash::Vivify is useful for detecting this: my $hashref = Tie::Hash::Vivify-new(sub { confess(No auto-vivifying (did you mis-spell something?)\n.Dumper(\...@_)) });

Re: Perl Critic and (honest) hash references

2009-03-02 Thread Joshua ben Jore
On Wed, Feb 18, 2009 at 8:05 AM, Roger Hall raha...@ualr.edu wrote: All, ... Do I have to redesign the module to get past this syntatical doppelganger? If you redesigned, replacing your hash with an array would be harder to typo, faster, smaller, not as nice to dump with Dumper, and harder

Re: Perl Critic and (honest) hash references

2009-03-02 Thread Eric Wilhelm
# from Joshua ben Jore # on Monday 02 March 2009 08:20: If you redesigned, replacing your hash with an array would be harder to typo, faster, smaller, not as nice to dump with Dumper, and harder for 3rd parties to extend. Is harder to extend a design goal? You also make it harder to use. And

Re: Perl Critic and (honest) hash references

2009-03-02 Thread Bill Ward
On Mon, Mar 2, 2009 at 10:09 AM, Eric Wilhelm enoba...@gmail.com wrote: # from Joshua ben Jore # on Monday 02 March 2009 08:20: If you redesigned, replacing your hash with an array would be harder to typo, faster, smaller, not as nice to dump with Dumper, and harder for 3rd parties to

Re: Perl Critic and (honest) hash references

2009-03-02 Thread David Cantrell
On Mon, Mar 02, 2009 at 10:09:00AM -0800, Eric Wilhelm wrote: # from Joshua ben Jore # on Monday 02 March 2009 08:20: If you redesigned, replacing your hash with an array would be harder to typo, faster, smaller, not as nice to dump with Dumper, and harder for 3rd parties to extend. Is

Re: Perl Critic and (honest) hash references

2009-03-02 Thread Nicholas Clark
On Mon, Mar 02, 2009 at 10:23:38AM -0800, Bill Ward wrote: Personally I always use hashes for objects. Hashes are pretty fast in Perl, especially when there aren't many keys, so I don't think the benefits of using arrays are worth it. The risk of typos is pretty small, and the Hash lookup

Re: Perl Critic and (honest) hash references

2009-03-02 Thread Joshua ben Jore
On Mon, Mar 2, 2009 at 12:22 PM, Nicholas Clark n...@ccl4.org wrote: On Mon, Mar 02, 2009 at 10:23:38AM -0800, Bill Ward wrote: Personally I always use hashes for objects.  Hashes are pretty fast in Perl, especially when there aren't many keys, so I don't think the benefits of using arrays

Re: Perl Critic and (honest) hash references

2009-03-02 Thread Bill Ward
On Mon, Mar 2, 2009 at 12:22 PM, Nicholas Clark n...@ccl4.org wrote: On Mon, Mar 02, 2009 at 10:23:38AM -0800, Bill Ward wrote: Personally I always use hashes for objects. Hashes are pretty fast in Perl, especially when there aren't many keys, so I don't think the benefits of using

Re: Perl Critic and (honest) hash references

2009-02-19 Thread David Cantrell
On Wed, Feb 18, 2009 at 12:58:46PM -0800, Ovid wrote: Mostly agreed. Objects should be about responsibilities (behavior) and not so much about state (data). That being said, hashes are notorious for $gimme-{feild} (note the misspelling) Tie::Hash::Vivify is useful for detecting this: my

Re: Perl Critic and (honest) hash references

2009-02-18 Thread Shlomi Fish
On Wednesday 18 February 2009 18:05:13 Roger Hall wrote: All, I'm a fan of Class::Std and Dr. Conway's efforts, but I'm bemused by a failing perlcritic test on a new module. I used a hash reference to hold several values to make it easier to dump with YAML, so my code is peppered with code

RE: Perl Critic and (honest) hash references

2009-02-18 Thread Roger Hall
...@iglu.org.il] Sent: Wednesday, February 18, 2009 11:14 AM To: module-authors@perl.org; raha...@ualr.edu Subject: Re: Perl Critic and (honest) hash references On Wednesday 18 February 2009 18:05:13 Roger Hall wrote: All, I'm a fan of Class::Std and Dr. Conway's efforts, but I'm bemused

Re: Perl Critic and (honest) hash references

2009-02-18 Thread Ovid
- Original Message From: Roger Hall raha...@ualr.edu Personally though, I wouldn't create an object unless there were methods (which there are not in this case). Without methods, an object just seems like a too-fat hash to me! :} Mostly agreed. Objects should be about

Re: Perl Critic and (honest) hash references

2009-02-18 Thread Dana Hudes
The spelling issue in hash is resolved with the use fields pragma. That requires you predeclare (horrors!) your hash keys. --Original Message-- From: Ovid To: raha...@ualr.edu To: Shlomi Fish To: module-authors@perl.org Sent: Feb 18, 2009 3:58 PM Subject: Re: Perl Critic and (honest

Re: Perl Critic and (honest) hash references

2009-02-18 Thread nadim khemir
On Wednesday 18 February 2009 22.04.27 Dana Hudes wrote: The spelling issue in hash is resolved with the use fields pragma. That requires you predeclare (horrors!) your hash keys. That is in no way different from using strict and having to declare your variables. It might heavy but in no way