develooper Front page | perl.perl5.porters | Postings from June 2022

Re: pre-RFC: template strings

Thread Previous | Thread Next
From:
Oodler 577 via perl5-porters
Date:
June 15, 2022 12:35
Subject:
Re: pre-RFC: template strings
Message ID:
YqnSDC6SPr/i+sqO@odin.sdf-eu.org
* Ricardo Signes <perl.p5p@rjbs.manxome.org> [2022-06-12 21:39:27 -0400]:

> On Sun, Jun 12, 2022, at 17:36, Graham Knop wrote:
> > I like the general idea. I don't really like the spelling though, as ${ } already has meaning in the language and in interpolated strings.  I'd say that the @{} form is not needed. Eliminating it could allow a better spelling for the ${ } form.
> > 
> > Prior art: https://metacpan.org/pod/Quote::Code
> 
> Thanks.  If we have only one form, I'd suggest we use `#{ ... }` from Ruby.
> 
> Quote::Code raises a good point:  this would be useful in heredocs.  I'll think about it.

I agree; but in the example from Q::C:

    my $heredoc = qc_to <<'EOT';
    .trigger:hover .message:after {
      content: "The #{get_adjective()} brown fox #{get_verb()} over the lazy dog.";
    }
    EOT
    print $heredoc;

It'd be more consistent for it to be, (hint: s/#/&/):

    my $heredoc = qc_to <<'EOT';
    .trigger:hover .message:after {
      content: "The &{get_adjective()} brown fox &{get_verb()} over the lazy dog.";
    }
    EOT
    print $heredoc;

Q::C doesn't mention the rationale for '#" over '&' in this case, nor can I
think of a reason to not use it here for the subroutine call. Besides, it could
get a little confusing since bare '#' indicates a comment.

Cheers,
Brett

> 
> -- 
> rjbs

-- 
--
oodler@cpan.org
oodler577@sdf-eu.org
SDF-EU Public Access UNIX System - http://sdfeu.org
irc.perl.org #openmp #pdl #native

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