develooper Front page | perl.perl5.porters | Postings from July 2016

Re: Indented here docs?

Thread Previous | Thread Next
From:
H.Merijn Brand
Date:
July 1, 2016 11:03
Subject:
Re: Indented here docs?
Message ID:
20160701130324.4960171d@pc09.procura.nl
On Fri, 1 Jul 2016 10:38:28 +0000 (UTC), Ed Avis <eda@waniasset.com>
wrote:

> If this is added, there need to be checks that the indentation is consistent
> through the heredoc.  So for example this would not be allowed:
> 
> 
>     $foo = <<~END;
>     hello
>   there
>     END
> 
> Error at line 3: leading indentation on line is less than the indentation of
> the end delimiter.
> 
> At least, I would prefer that.  This restriction could be relaxed later if it
> turns out to get in the way, but it would be hard to add it if it weren't
> there originally, so I suggest it's safer to include the restriction in the
> first version of this new feature.

And what about - oh horror - mixed tabs and spaces?
Should it auto-expand leading whitespace?

<TAB><SPACE> is just three characters, <SPACE>{9} is nine characters.
Would you see the difference in

    my $foo = <<~"EOM";
	 First line
         Second line
  	 EOM
    my $bar = $foo;

Looks (visually) correct, right? But it is three different leading space

-- 
H.Merijn Brand  http://tux.nl   Perl Monger  http://amsterdam.pm.org/
using perl5.00307 .. 5.23   porting perl5 on HP-UX, AIX, and openSUSE
http://mirrors.develooper.com/hpux/        http://www.test-smoke.org/
http://qa.perl.org   http://www.goldmark.org/jeff/stupid-disclaimers/

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