develooper Front page | perl.perl6.language | Postings from May 2007

Re: explicit line termination with ";": why?

Thread Previous | Thread Next
From:
John Macdonald
Date:
May 14, 2007 18:29
Subject:
Re: explicit line termination with ";": why?
Message ID:
20070515030244.GC32504@lupus.perlwolf.com
On Tue, May 15, 2007 at 02:02:06AM +0200, Thomas Wittek wrote:
> John Macdonald schrieb:
> > It's also, in many cases,
> > harder to edit - that's why a trailing comma in a list that
> > is surrounded by parens, or a trailing semicolon in a block
> > surrounded by braces, is easier to manage.
> 
> Now that the list is surrounded by parens makes clear that it ends with
> the closing paren and not with a line break. So you could still use
> commas (without backslashes) to separate the items over multiple lines.
> See e.g. http://docs.python.org/ref/implicit-joining.html

I was actually talking about existing perl5 here.  I write:

my %h = (
	x => 100,
	y => 75,
	z => 99,
    );

explicitly writing the "unrequired" comma on the last element
(z=>99).  That way, if I add another element to the hash there's
no danger that I will forget to go back and add the comma to
the line above.  Alternately, if I reorder the hash elements
(maybe sorting on the value instead of the key) I don't have
to check whether there is now a commaless line in the middle
of the reordered bunch.

-- 

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About