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

[perl #127640] RFE: "qqw( $var/x $var/y word3 $var4=word4 )"

Thread Previous | Thread Next
From:
Father Chrysostomos via RT
Date:
March 11, 2016 05:52
Subject:
[perl #127640] RFE: "qqw( $var/x $var/y word3 $var4=word4 )"
Message ID:
rt-4.0.18-3325-1457675524-1313.127640-15-0@perl.org
On Thu Mar 10 16:01:19 2016, perl.p5p@rjbs.manxome.org wrote:
> * Aristotle Pagaltzis <pagaltzis@gmx.de> [2016-03-05T16:59:38]
> > > On Sat Mar 05 10:14:48 2016, perl.p5p@rjbs.manxome.org wrote:
> > > > $x = "good job";
> > > > @y = qqw( $x hunter );
> > > >
> > > > Is @y now ('good', 'job', 'hunter') or ('good job', 'hunter')?
> > > > I would think the latter.
> > >
> > I prefer the [latter].
> 
> Me, too.  Other cases to consider:
> 
> @x = qqw(  abc @def ghi );
> 
> ...which would need to have three elements, to match this:
> 
> @x = qqw(  x:abc x:@def x:ghi  );
> 
> It would be bizarre for the second example to only have x: on the
> first element
> from @def.  If @def is empty, it ought to become "", similarly.

Would you please clarify with examples? Does x:@def above become one element of @x, or does it fill @x with as many elements as are in @def?

> 
> Someone will probably have to stop and think about:
> 
> @x = qqw(
>   abc
>   $def->{ ... ... ... }
>   ghi
> );
> 
> ...because of the spaces in the expr in the second element.  I think
> this is
> okay.

You just switch to a different parsing style when you encounter the $.  Standard double-quote parsing solves it that way.

<wishful thinking>

That said, I wish we could solve this kind of nonsense:

  qq<$x{">"}>;  # syntax error

If strings were parsed just like blocks of code, there would be no reason for that not to work.  After all, { "}" } and ["]"] work.  As it is, the final delimiter of the string is searched for before the body is parsed.  It has to be that way for quote-like operators with flags at the end.

It would have been saner if the parsing had been done the other way round from day 1 (with the flags in some other spot).

Would it be possible to make qqw work the ‘new’ way?  Or would it be to confusing if it does not conform to the way qw works?

</wishful>

> 
> > While we’re at it – I would also prefer qqw() to allow comments,
> > and/but
> > allow backslashing whitespace and octothorpes to demote them from
> > syntax
> > to string content.
> 
> Agreed.
> 
> > Oh, and please – no qw()-style warnings about commas.
> 
> I have no feelings on this.

That is one of the most annoying warnings.  If it warned *only* when all the elements are comma-separated, it would be helpful for new bees without annoying people trying to do this:  qw( . , ; : ) etc.  Currently, just *one* comma anywhere in the qw will raise the warning.

If we could restrict the warning that way, I would not mind it on qqw.  It might be good to apply the restriction to qw as well.

-- 

Father Chrysostomos


---
via perlbug:  queue: perl5 status: open
https://rt.perl.org/Ticket/Display.html?id=127640

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