Re: bad code to good golf

2007-12-13 Thread shmem
Hello aristotle, hello all, no good to hide away... *sigh* From the keyboard of A. Pagaltzis [10.12.07,13:41]: * shmem [EMAIL PROTECTED] [2007-12-10 12:55]: Well, if we were to return an array reference instead of a hash ref, sub [EMAIL PROTECTED],shift} works. Why does the shift

Re: bad code to good golf

2007-12-10 Thread shmem
From the keyboard of A. Pagaltzis [09.12.07,21:50]: * Marcus Holland-Moritz [EMAIL PROTECTED] [2007-12-09 21:20]: We're all stuck at 21. :-) Well, `bless`, `shift` or `$_[0]`, `{}`, [EMAIL PROTECTED], and one comma are all inevitable. That's 15 characters in fixed strings alone. Then

Re: bad code to good golf

2007-12-10 Thread A. Pagaltzis
* shmem [EMAIL PROTECTED] [2007-12-10 12:55]: Well, if we were to return an array reference instead of a hash ref, sub [EMAIL PROTECTED],shift} works. Why does the shift get executed before an array reference is constructed - but not if a hashref is constructed - from an array? It

Re: bad code to good golf

2007-12-10 Thread Uri Guttman
AP == A Pagaltzis [EMAIL PROTECTED] writes: AP * shmem [EMAIL PROTECTED] [2007-12-10 12:55]: Well, if we were to return an array reference instead of a hash ref, sub [EMAIL PROTECTED],shift} AP In contrast, the hash constructors make a *copy* of the array, AP and that copy

Re: bad code to good golf

2007-12-10 Thread Steve Fink
On Dec 10, 2007 3:53 AM, shmem [EMAIL PROTECTED] wrote: Well, if we were to return an array reference instead of a hash ref, sub [EMAIL PROTECTED],shift} works. Why does the shift get executed before an array reference is constructed - but not if a hashref is constructed - from an array? No

Re: bad code to good golf

2007-12-09 Thread Marcus Holland-Moritz
On 2007-12-09, at 00:28:08 -0800, Michael G Schwern wrote: Uri Guttman wrote: i have two solutions of 33 and 24 chars so you have to beat those. the longer one is amusing enough to show it later. sub new [EMAIL PROTECTED],shift} Was my first shot at 23. Then I figured I could knock

Re: bad code to good golf

2007-12-09 Thread robert wilson
On Sunday 09 December 2007, Michael G Schwern (Michael G Schwern [EMAIL PROTECTED]) wrote: sub new [EMAIL PROTECTED],shift} Was my first shot at 23. Then I figured I could knock off that range op... my first shot was 23 also... sub new{($a,@b)[EMAIL PROTECTED];[EMAIL PROTECTED],$a} then i

Re: bad code to good golf

2007-12-09 Thread Uri Guttman
MGS == Michael G Schwern [EMAIL PROTECTED] writes: even better than just be a poorly written constructor is that it is inside a 'factory' module that is inherited by 80 other modules!! MGS If that's an example of poorly written code in your project, MGS can I come work there? It at

Re: bad code to good golf

2007-12-09 Thread Uri Guttman
rw == robert wilson [EMAIL PROTECTED] writes: rw On Sunday 09 December 2007, Michael G Schwern (Michael G Schwern rw [EMAIL PROTECTED]) wrote: sub new [EMAIL PROTECTED],shift} Was my first shot at 23. Then I figured I could knock off that range op... rw my first shot was 23

Re: bad code to good golf

2007-12-09 Thread Marcus Holland-Moritz
On 2007-12-09, at 13:23:11 -0500, Uri Guttman wrote: MGS == Michael G Schwern [EMAIL PROTECTED] writes: MGS sub new {$a=shift;[EMAIL PROTECTED],$a} MGS 21. And it's even strict clean. :) that is nice. the other replies beat it though! Nope, Michael's solution is just as short.

Re: bad code to good golf

2007-12-09 Thread A. Pagaltzis
* Uri Guttman [EMAIL PROTECTED] [2007-12-09 19:25]: * Michael G Schwern [EMAIL PROTECTED] writes: sub new { my $class = shift; return bless( [EMAIL PROTECTED], $class ); } my clean version is: sub new { my ( $class, %self ) = @_ ; return bless \%self, $class ; } i

Re: bad code to good golf

2007-12-09 Thread Michael G Schwern
A. Pagaltzis wrote: * Uri Guttman [EMAIL PROTECTED] [2007-12-09 19:25]: i don't like using shift for args if i can help it. Personally I *always* use `shift` for the invocant, but assignment from [EMAIL PROTECTED] for all other parameters in all but a few rare circumstances. So methods in

Re: bad code to good golf

2007-12-09 Thread Michael G Schwern
Uri Guttman wrote: is there any guarantee of evaluation order in arg lists? will the bless/splice always be executed before the pop? I believe it is undefined, so it's not recommended that you do anything order dependent in the argument list. But it is stable. As implemented, complex

Re: bad code to good golf

2007-12-09 Thread Uri Guttman
MGS == Michael G Schwern [EMAIL PROTECTED] writes: MGS Uri Guttman wrote: is there any guarantee of evaluation order in arg lists? will the bless/splice always be executed before the pop? MGS I believe it is undefined, so it's not recommended that you do MGS anything order dependent