develooper Front page | perl.perl6.language | Postings from June 2005

Re: sub my_zip (...?) {}

Thread Previous | Thread Next
From:
Larry Wall
Date:
June 16, 2005 14:16
Subject:
Re: sub my_zip (...?) {}
Message ID:
20050616211553.GA17308@wall.org
On Thu, Jun 16, 2005 at 01:05:22PM -0700, Dave Whipp wrote:
: Larry Wall wrote:
: > You must
: >specify @foo[[;]@bar] or @foo[()] <== @bar to get the special mark.
: 
: I'm uncomfortable with the  specific syntax of @a[()] because generated 
: code might sometimes want to generate an empty list, and special-casing 
: that sort of thing is always a pain (and fragile). An empty list of 
: subscripts should return an empty slice.

If you don't actually pipe to it, a null list is exactly what it would be
interpreted as, so I don't think it's a very big problem.  And outside
of generated code, () is always intentional.  If there's a potential
problem, it's with expecting

    @a ==>
	foo().bar()

to feed bar() rather than foo().  So maybe that would have to be written

    @a ==>
	foo().bar(())

or

    @a ==>
	foo(()).bar()

Or maybe as you say we just need a special term, though I don't think ...
is it.

: What this mark is really trying to say is "The definition of the indices 
: is coming from elsewhere". I'm wondering if these semtantics would make 
: it appropriate to use the yada operator here:
: 
:    @foo[...] <== @bar;

That's cute, but I think that might be overloading the ... token a
bit too much, and it's also rather likely to be confused with the
postfix ... operator within subscripts.  These would be too close,
visually speaking:

    @foo[...]
    @foo[0...]

I suppose a case could be made for

    @foo[@=]

or some such, since it's an inside out iterator.  But () is prettier.
Alternately we could go with the unix pipe character:

    @foo[|]

Or maybe a splat

    @foo[*]

Or go with the parens with something in them to indicate the positive
absence of something.

    @foo[(*)]

Anyone else want to have a go at this bikeshed?

Larry

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