From nickwoolley at yahoo.co.uk Mon Sep 3 09:28:14 2007 From: nickwoolley at yahoo.co.uk (Nick Woolley) Date: Mon, 03 Sep 2007 17:28:14 +0100 Subject: [Edinburgh-pm] Not the Hash:-) In-Reply-To: References: Message-ID: <46DC361E.2080007@yahoo.co.uk> Just for the record: "me too". From rory.macdonald at gmail.com Wed Sep 5 10:50:53 2007 From: rory.macdonald at gmail.com (Rory Macdonald) Date: Wed, 5 Sep 2007 18:50:53 +0100 Subject: [Edinburgh-pm] Not the Hash:-) In-Reply-To: References: Message-ID: Can't make it next week, but look forward to some pics online. Rory From Ian.Stuart at ed.ac.uk Thu Sep 6 00:49:54 2007 From: Ian.Stuart at ed.ac.uk (Ian Stuart) Date: Thu, 06 Sep 2007 08:49:54 +0100 Subject: [Edinburgh-pm] Parameter passing, seeking an answer.... Message-ID: <46DFB122.9040105@ed.ac.uk> When I first started coding, I'd pick up parameters in functions thus: sub myFunc { my self = shift; # stuff } I've noticed that people have moved to a new style: sub myFunc { my ($self) = @_; # stuff } Is there a good compelling reason for this (new to me) style? -- Ian "Perl Laghu" Stuart. From rory.macdonald at gmail.com Thu Sep 6 01:26:47 2007 From: rory.macdonald at gmail.com (Rory Macdonald) Date: Thu, 6 Sep 2007 09:26:47 +0100 Subject: [Edinburgh-pm] Parameter passing, seeking an answer.... In-Reply-To: <46DFB122.9040105@ed.ac.uk> References: <46DFB122.9040105@ed.ac.uk> Message-ID: On 9/6/07, Ian Stuart wrote: > When I first started coding, I'd pick up parameters in functions thus: > > sub myFunc { > my self = shift; > # stuff > } > > I've noticed that people have moved to a new style: > > sub myFunc { > my ($self) = @_; > # stuff > } > > Is there a good compelling reason for this (new to me) style? Without context? No. But there's nothing new about it. Depends on what you've been reading I guess. If you had to scratch for reasons to do "my ($self) = @_;" then; * its less code to change if you add to the parameter list * its fewer instructions/lines if you add more params than a series of shifts (although it may well be optimized down to the same thing as the "() = @_" behind the scenes?) * in a code base where various functions accept varying numbers of params, then consistency in this area may help maintenance (think coding standards) Rory From perl at minty.org Thu Sep 6 01:32:44 2007 From: perl at minty.org (Murray) Date: Thu, 6 Sep 2007 09:32:44 +0100 Subject: [Edinburgh-pm] Parameter passing, seeking an answer.... In-Reply-To: <46DFB122.9040105@ed.ac.uk> References: <46DFB122.9040105@ed.ac.uk> Message-ID: <20070906083244.GM7678@minty.org> On Thu, Sep 06, 2007 at 08:49:54AM +0100, Ian Stuart wrote: > my $self = shift; > my ($self) = @_; In the above case, one less character. my ($foo, $bar, $baz) = @_; my ($foo, $bar, $baz) = (shift, shift, shift); Much shorter. You can also have: my ($foo, $bar, @moo) = @_; But note that: my (@foo, $zoo, $bat) = @_; Is probably not what you want because @foo will suck up everything, leaving $zoo and $bat undef. From kevin at theconfused.co.uk Thu Sep 6 01:34:45 2007 From: kevin at theconfused.co.uk (Kevin White) Date: Thu, 6 Sep 2007 09:34:45 +0100 Subject: [Edinburgh-pm] Parameter passing, seeking an answer.... In-Reply-To: <46DFB122.9040105@ed.ac.uk> References: <46DFB122.9040105@ed.ac.uk> Message-ID: Hi Ian, I don't know about compelling reason, I have a tendency to use the former just because it is clear what I am taking off. The only time I tend to use @_ is if I am using Params::Validate. Kevin On 6 Sep 2007, at 08:49, Ian Stuart wrote: > When I first started coding, I'd pick up parameters in functions thus: > > sub myFunc { > my self = shift; > # stuff > } > > I've noticed that people have moved to a new style: > > sub myFunc { > my ($self) = @_; > # stuff > } > > Is there a good compelling reason for this (new to me) style? > > -- > > Ian "Perl Laghu" Stuart. > > _______________________________________________ > Edinburgh-pm mailing list > Edinburgh-pm at pm.org > http://mail.pm.org/mailman/listinfo/edinburgh-pm -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/edinburgh-pm/attachments/20070906/43b418f4/attachment.html From ben.soares at ed.ac.uk Thu Sep 6 01:53:07 2007 From: ben.soares at ed.ac.uk (Ben Soares) Date: Thu, 06 Sep 2007 09:53:07 +0100 Subject: [Edinburgh-pm] Parameter passing, seeking an answer.... In-Reply-To: <46DFB122.9040105@ed.ac.uk> References: <46DFB122.9040105@ed.ac.uk> Message-ID: <1189068787.28842.16.camel@callisto> When using a "named" parameters method I like to do sub myFunc { my ($self, %params) = @_; if ($params{"-filename"}) { &etc(); } } Ben PS You could have asked me over the partition ;) On Thu, 2007-09-06 at 08:49 +0100, Ian Stuart wrote: > When I first started coding, I'd pick up parameters in functions thus: > > sub myFunc { > my self = shift; > # stuff > } > > I've noticed that people have moved to a new style: > > sub myFunc { > my ($self) = @_; > # stuff > } > > Is there a good compelling reason for this (new to me) style? > From Ian.Stuart at ed.ac.uk Thu Sep 6 01:58:32 2007 From: Ian.Stuart at ed.ac.uk (Ian Stuart) Date: Thu, 06 Sep 2007 09:58:32 +0100 Subject: [Edinburgh-pm] Parameter passing, seeking an answer.... In-Reply-To: <1189068787.28842.16.camel@callisto> References: <46DFB122.9040105@ed.ac.uk> <1189068787.28842.16.camel@callisto> Message-ID: <46DFC138.3090205@ed.ac.uk> Ben Soares wrote: > When using a "named" parameters method I like to do > > sub myFunc { > my ($self, %params) = @_; > if ($params{"-filename"}) { > &etc(); > } > } For multi-parameter passes, my ($a, $b, $c) = @_ has lots of advantages. Like Ben, I'm definitely moving towards the idea of passing in "named" parameters as it means that parameters can be passed in any order, and any number of parameters can be optional > PS You could have asked me over the partition ;) I could, except there is a particularly large partition today: you're tele-working :chuckle: -- Ian Stuart. Bibliographics and Multimedia Service Delivery team, EDINA, The University of Edinburgh. http://edina.ac.uk/ From perl at aaroncrane.co.uk Thu Sep 6 02:26:53 2007 From: perl at aaroncrane.co.uk (Aaron Crane) Date: Thu, 6 Sep 2007 10:26:53 +0100 Subject: [Edinburgh-pm] Parameter passing, seeking an answer.... In-Reply-To: <46DFB122.9040105@ed.ac.uk> References: <46DFB122.9040105@ed.ac.uk> Message-ID: <20070906092653.GR1291@aaroncrane.co.uk> Ian Stuart writes: > sub myFunc { > my self = shift; > } > > sub myFunc { > my ($self) = @_; > } > > Is there a good compelling reason for this (new to me) style? Unpacking @_ with a direct list assignment is more concise, and collecting several arguments in a horizontal list tends to make your code more readable. (As long as the list isn't too long, anyway, but in that case, you probably want to refactor your function so that it doesn't take so many positional arguments.) The list-assignment approach also lets your argument-unpacking code visually mimic the calling syntax. Here's an example from a piece of code I happen to have open right now. The list-assignment version sub set_teasers { my ($db, $slot_id, $contents) = @_; # ... } is much more concise (and, I believe, more readable) than sub set_teasers { my $db = shift; my $slot_id = shift; my $contents = shift; # ... } In particular, this form of concision saves screen lines. That's particularly valuable given that screen lines are one of the few non-renewable resources we have: as screens get physically larger, you have to put them further away from your eyes to be able to see the whole screen comfortably, so there's a hard limit on the number of lines you can see at once. Some people prefer to use shift for method invocants, but unpack other arguments with a single list assignment: sub send { my $self = shift; my ($sender, $recipient, $message) = @_; # ... } That makes the method definition reflect the calling syntax, in which the invocant is separated from the other arguments: $smtp->send($sender, $recipient, $message) But you still have to pay for that by spending an extra line on merely unpacking your parameters. Damian Conway recommends ("Perl Best Practices", O'Reilly, 2005) using shift to unpack arguments in situations where "one or more of them has to be sanity-checked, or needs to be documented with a trailing comment", and offers this example: sub padded { my $text = _check_non_empty(shift); my $cols_count = _limit_to_positive(shift); my $want_centering = shift; # ... } As with all stylistic questions, though, the most important thing is consistency across a single codebase: if your team has agreed on one particular style, then adopting that style makes the whole codebase easier to read. -- Aaron Crane From robert at interactive.co.uk Mon Sep 10 10:33:08 2007 From: robert at interactive.co.uk (Robert Inder) Date: 10 Sep 2007 18:33:08 +0100 Subject: [Edinburgh-pm] OK Croquet... In-Reply-To: Message-ID: OK, so this Wednesday is the (not very) long awaited Permongers Croquet Outing. Seven of you have said you're interested, so we should have a lawn-full. ((Now there's an unusual collective noun: a lawnful of programmers...)) THIS MEANS THAT, with that many of "The Usual Suspects" being in Tollcross, it seems to me quite possible that the September Perlmongers meeting will be happening in Cloisters, not the Guildford... I'm going to mail those who have signed up directly with details. If you don't get mail from me, and you think you've signed up, phone! ALSO, we could sensibly accommodate one more (if I don't actually play), so there is one more place available to the first person to phone to ask for it! Robert. -- Robert Inder Interactive Information Ltd, Registered in Scotland 07808 492 213 3, Lauriston Gardens, Company no. SC 150689 0131 229 1052 Edinburgh EH3 9HH SCOTLAND UK Interactions speak louder than words From perl at aaroncrane.co.uk Wed Sep 12 06:33:49 2007 From: perl at aaroncrane.co.uk (Aaron Crane) Date: Wed, 12 Sep 2007 14:33:49 +0100 Subject: [Edinburgh-pm] OK Croquet... In-Reply-To: References: Message-ID: <20070912133349.GA20448@aaroncrane.co.uk> Robert Inder writes: > THIS MEANS THAT, with that many of "The Usual Suspects" being in > Tollcross, it seems to me quite possible that the September > Perlmongers meeting will be happening in Cloisters, not the > Guildford... That seems likely to me also. Anyone not planning to come to the Croquet Extravaganza but who wants to join us for food and/or drinks later, feel free to mail me for my mobile number. See you later. -- Aaron Crane From perl at minty.org Thu Sep 13 03:15:34 2007 From: perl at minty.org (Murray) Date: Thu, 13 Sep 2007 11:15:34 +0100 Subject: [Edinburgh-pm] Emergency Whisky Social Message-ID: <20070913101534.GW7678@minty.org> Silly comments by me about not drinking so much aside, I'm proposing a night of whisky at the Scotch Malt Whisky Society. Open to perl people and friends. There is Queen Street or down Leith way. Vote for the day that works best for you: http://doodle.ch/33mkxqdyqbbck8m7 (This is in addition to the regular, 2nd Wed of the month, meeting). From perl at minty.org Thu Sep 13 04:49:55 2007 From: perl at minty.org (Murray) Date: Thu, 13 Sep 2007 12:49:55 +0100 Subject: [Edinburgh-pm] OK Croquet... In-Reply-To: References: Message-ID: <20070913114955.GA7678@minty.org> (This should have preceded my previous email, had I sent from the correct address). Very enjoyable evening. Thanks for arranging! Against my better judgement I'm tempted to say there is something to this eating lark rather than drinking solidly from 6 until closing. I felt positively not hung over this morning. Murray. From asmith9983 at gmail.com Thu Sep 13 05:28:11 2007 From: asmith9983 at gmail.com (asmith9983 at gmail.com) Date: Thu, 13 Sep 2007 13:28:11 +0100 (BST) Subject: [Edinburgh-pm] OK Croquet... In-Reply-To: <20070913114955.GA7678@minty.org> References: <20070913114955.GA7678@minty.org> Message-ID: Hi Murray I thought you were stating the bleeding obvious!! I wasn't along on Wed evening as I am in resting mode for the Cycle Scotland Glasgow-Edinburgh cycle on Sunday. -- Andrew On Thu, 13 Sep 2007, Murray wrote: > (This should have preceded my previous email, had I sent from the > correct address). > > Very enjoyable evening. Thanks for arranging! > > Against my better judgement I'm tempted to say there is something to > this eating lark rather than drinking solidly from 6 until closing. I > felt positively not hung over this morning. > > Murray. > _______________________________________________ > Edinburgh-pm mailing list > Edinburgh-pm at pm.org > http://mail.pm.org/mailman/listinfo/edinburgh-pm > From perl at minty.org Mon Sep 24 01:24:30 2007 From: perl at minty.org (Murray) Date: Mon, 24 Sep 2007 09:24:30 +0100 Subject: [Edinburgh-pm] Whiskey, Thur 27th Sept. Message-ID: <20070924082424.GO18081@minty.org> Survey says [1] this thursday (sorry Anthony!) Scotch Malt Whiskey Society [2] 87 Giles Street Edinburgh EH6 6BZ http://maps.google.com/?q=EH6+6BZ I should be there about 6.30 ish. If you are planning to come along, could you let me know so I can keep a count of members/non-members and ensure the upload^^^^^ ratio remains above 1. Murray. [1] http://doodle.ch/33mkxqdyqbbck8m7 [2] http://www.smws.co.uk/index.php From robert at interactive.co.uk Mon Sep 24 03:36:29 2007 From: robert at interactive.co.uk (Robert Inder) Date: 24 Sep 2007 11:36:29 +0100 Subject: [Edinburgh-pm] Whiskey, Thur 27th Sept. In-Reply-To: <20070924082424.GO18081@minty.org> References: <20070924082424.GO18081@minty.org> Message-ID: >>>>> Murray writes: > Date: Mon, 24 Sep 2007 09:24:30 +0100 > To: edinburgh-pm at pm.org > Subject: [Edinburgh-pm] Whiskey, Thur 27th Sept. > Survey says [1] this thursday (sorry Anthony!) > Scotch Malt Whiskey Society [2] Scotch Malt WhisKEY Society?! I know they're trying to attract an international audience, but I don't think they've gone THAT far... Robert. -- Robert Inder Interactive Information Ltd, Registered in Scotland 07808 492 213 3, Lauriston Gardens, Company no. SC 150689 0131 229 1052 Edinburgh EH3 9HH SCOTLAND UK Interactions speak louder than words From perl at minty.org Mon Sep 24 03:39:10 2007 From: perl at minty.org (Murray) Date: Mon, 24 Sep 2007 11:39:10 +0100 Subject: [Edinburgh-pm] Whiskey, Thur 27th Sept. In-Reply-To: References: <20070924082424.GO18081@minty.org> Message-ID: <20070924103910.GU18081@minty.org> > Scotch Malt WhisKEY Society?! I blame becky.