develooper Front page | perl.perl6.language | Postings from November 2004

Re: Angle quotes and pointy brackets

From:
Larry Wall
Date:
November 30, 2004 14:24
Subject:
Re: Angle quotes and pointy brackets
Message ID:
20041130222357.GE30391@wall.org
On Tue, Nov 30, 2004 at 10:05:03PM +0000, Matthew Walton wrote:
: So
: 
: my @list = <foo bar baz>;
: 
: is the equivalent of
: 
: my @list = ('foo', 'bar', 'baz');
: 
: ?

Yes.

: >    * Since we already stole angles from iterators, «$fh» is not
: >	how you make iterators iterate.  Instead we use $fh.fetch (or
: >	whatever) in scalar context, and $fh.fetch or @$fh or $fh[]
: >	or *$fh in list context.
: 
: That's doable. I take it that if I do
: 
: for (@$fh) {
:   ...
: }
: 
: then $fh iterates lazily rather than exploding into an enormous list to 
: be processed and chewing up all the RAM.

Correct.  The p5-to-p6 translator will turn any

    while (<handle>) {...}

into

    for @$handle {...}

or whatever we decide is the correctest idiom.

: >    * That frees up «...» for Something Else.
: >
: >    * That something else is the requested variant of qw// that allows
: >	interpolation and quoting of arguments in a shell-like manner.
: 
: Mmmm so I can write
: 
: my $foo = 'foo';
: my $bar = 'bar';
: my $baz = 'baz';
: my @list = «$foo $bar $baz»;
: 
: and get the same @list I got earlier? Mighty cool.

I thought so.

: I don't think I've ever used a hash slice in my life. Is there something 
: wrong with me?

No, a lot of people are naturally monoindexous.

: >    * The Texas quotes <<...>> are only needed when you *have* to 
: >    interpolate.
: 
: Does
: 
: <<foo bar baz>>
: 
: mean
: 
: «foo bar baz»
: 
: or
: 
: ('<foo', 'bar', 'baz>')
: 
: ?

The former.  The <<...>> workaround is still the same, but needed a lot less.

: >    * The :w splitting happens after interpolation.  So
: >
: >	    « foo $bar @baz »
: >
: >	can end up with lots of words, while
: >
: >	    « foo "$bar" "@baz" »
: >
: >	is guaranteed to end up with three "words".
: 
: See the comment about 'fabulouser' above and add another 'and 
: fabulouser' to the end.

I neglected to mention that the smart quoter should also recognize
pair notation and handle it.

: >    * Multimethed references could be distinghuised either way:
: >
: >	&bark«Tree»
: >	&bark<Dog>
: 
: Good, so those of us who wish to use as much Unicode as possible can do 
: so without having to rewrite the grammar. Excellent ;-)

I neglected to mention that we also naturally get both of:

    circumfix:«< >»
    circumfix:<« »>

in addition to

    circumfix:{'<','>'}
    circumfix:{'«','»'}

Have to be careful with

    circumfix:«{ }»

though, since {...} interpolates these days.

Larry



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About