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

Re: nothing

Thread Previous | Thread Next
From:
Larry Wall
Date:
March 21, 2005 09:32
Subject:
Re: nothing
Message ID:
20050321173228.GD27966@wall.org
On Sun, Mar 20, 2005 at 09:08:08PM -0600, Rod Adams wrote:
: Does Perl need a no-op function?
: 
: With the addition of "no bare literals", it makes constructs like
: 
: 1 while some_func();
: 
: an error.

Well, it's not a bareword--it's just potentially a useless use of
the value in a void context, and we could suppress that warning for
0 and 1 like we do Perl 5 without violating our "no barewords" dictum.

: I propose creating a no-op function "nothing" that can be used 
: here or anywhere else you specifically wish to do nothing at all.
: 
:  given $this {
:    when Even  { nothing };
:    when Prime { ... };
:    default    { ... };
:  }

We use <null> in rules, and Ada used "null" as a keyword, so I'd probably
prefer that if there are no serious objections and if nobody has a better
idea.

: As a side question, I assume that there's a predicate form of "when", 
: but it's not mentioned.
: 
:  given $this {
:    nothing when Even;
: 
:    when Prime { ... };
: 
:    default    { ... };
:  }

It's mentioned somewhere, I forget where, but its semantics are
currently defined such that it would not bypass the other cases.
It's possible that's a Surprise, but we were invisioning it as a
mechanism for adding extra tests against the topic when you don't
want to break out.  And we wanted to encourage people to use the
"comb structure" when they really are dealing with exclusive options.

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