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

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

Thread Previous | Thread Next
Larry Wall
June 16, 2005 14:16
Re: sub my_zip (...?) {}
Message ID:
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 ==>

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

    @a ==>


    @a ==>

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:


I suppose a case could be made for


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


Or maybe a splat


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


Anyone else want to have a go at this bikeshed?


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About