Front page | perl.perl5.porters |
Postings from July 2016
Re: Indented here docs?
Thread Previous
|
Thread Next
From:
Ævar Arnfjörð Bjarmason
Date:
July 23, 2016 14:43
Subject:
Re: Indented here docs?
Message ID:
CACBZZX5WpaYKDVd4qktpajOrpYLmpM-8LsUOee=OOCdOFQjGBQ@mail.gmail.com
On Mon, Jul 4, 2016 at 10:07 AM, Smylers <Smylers@stripey.com> wrote:
> Matthew Horsfall (alh) writes:
>
>> So far, it seems the changes I must make are:
>>
>> * Switch ~ to -
>
> You initially chose <<~ to match Ruby's similar operator. It's been
> pointed out that <<- is the Bash equivalent. So that's one reason each
> way. Is there any reason for Bash trump Ruby in this regard?
>
> For what it's worth, Bash's <<- strips all leading tab characters.
> Ruby's <<~ strips the indentation of the least-indented line. So we
> don't have quite the same behaviour as either of them.
>
> However, Ruby's operator for a ‘traditional’ here-doc that doesn't strip
> any indentation is, unfortunately <<-, which means:
>
> • If we go with <<~, Bash users have to learn a different operator for
> indentation-stripping here-docs in Perl.
As someone who makes heavy use of this in shell scripts and doesn't
use Ruby, I've been wanting this in perl for a long time. Thanks to
Matthew for working on it!
I think it would be much more confusing to emulate sh's "<<-" and
*not* have the same semantics. I think the semantics Matthew has
implemented here (I didn't know Ruby had this) are more useful than
sh's.
I think we should borrow syntax verbatim when we lift features pretty
much verbatim, but using the same syntax with different semantics is
even more confusing.
Which is to say I think we should keep the initially proposed "<<~" syntax.
> • If we go with <<-, Ruby users have to learn a different operator for
> indentation-stripping here-docs in Perl, and the operator they have to
> learn is the one they are used to for non-indentation-stripping
> here-docs.
>
> • Anybody who uses both Bash and Ruby already has to deal with this and
> whichever we pick isn't going to make things worse!
>
> Smylers
Thread Previous
|
Thread Next