On Tue, Apr 16, 2002 at 09:03:14AM -0700, David Wheeler wrote:
> On 4/16/02 7:43 AM, "Griffith, Shaun" <[EMAIL PROTECTED]> claimed:
>
> > So I take it readability is deprecated?
> >
> > For instance:
> >
> > $some_nested_hash{very_long_descriptive_key}{another_key}...{last_key}
> >
> > can no longer be broken into multiple lines, like this?
> >
> > $some_nested_hash{very_long_descriptive_key}
> > {another_key}
> > ...
> > {last_key}
> >
> > Or does it depend on whether {some_key} "looks like" a statement block or
> > not?
>
> IIUC, the no whitespace rule only applies before control structure blocks,
> such as if {} and while {}, because you need the space before the opening
> brace.
Eh, no. You got it backwards. It's not that you need a space before
a control block, it is that "If you put a space before a {, it *IS*
a control block".
It's the space that determines what follows is a control block.
> In other spaces, it's not necessary.
It's not that it isn't necessary. It's forbidden. Unlike in C, awk,
Java, Pascal, or even in the language of the whitespace, Python. Any
language I can remember programming in in the last 2 decades allows
optional whitespace between the aggregate and the index, without
parsing things differently.
> In other spaces, it's not necessary. So while you'll need to do this:
>
> %some_nested_hash{very_long_descriptive_key}
> {another_key}
> ...
> {last_key} = 'foo';
That's a syntax error. You've some stuff in void context, and then
you're assigning something to a block.
> You'll have to do this for control blocks:
The problem is, because the ()'s are dropped, the parser cannot know
where the control block starts, hence the new rule "any opening brace
following whitespace will be a block".
> if %some_nested_hash{very_long_descriptive_key}{another_key}...{last_key} {
> # do stuff
> }
>
> But if you really want to improve legibility, and you find you have a lot of
> this sort of thing in your code, I suggest you make a shortcut:
>
> my %scut = %some_nested_hash{very_long_descriptive_key}{another_key}{one};
>
> if %scut.{last_key} { # Perl 6 hashref syntax.
> # do stuff
> }
Having to *add* code isn't actually making a shortcut, is it? ;-)
Abigail