develooper Front page | perl.perl5.porters | Postings from August 2012

Re: fixing smartmatch (again (still))

Thread Previous | Thread Next
Ricardo Signes
August 28, 2012 16:08
Re: fixing smartmatch (again (still))
Message ID:
* David Golden <> [2012-08-28T18:52:35]
> On Tue, Aug 28, 2012 at 5:06 PM, Jesse Luehrs <> wrote:
> > I think people will have fewer reservations about accepting weird
> > special cases like this for a keyword-based control structure
> > (especially considering the precedent set by while (<>), etc) than for
> > an infix operator (since it will be a weird special case either way -
> > "why can i do '$foo ~~ 1', but not '$a = 1; $foo ~~ $a'?".
> >
> >
> The opportunity for confusion exists either way.  My suggestion is to
> change *one* thing -- smartmatch -- instead of *two* things -- smartmatch
> and when.

That's not quite true.  No matter what we're changing both.  Right now, when
has many special cases that are not smartmatch: perldoc perlsyn and search for
"Most of the power"

> Then all people have to know/relearn is the smartmatch table, not the
> smartmatch table *and* the special case rules for when.

This is true, though, if when has no special cases, and the way we change it is
to remove them all, leaving only "when ($smartmatch_rhs)"

I think there are merits to both that and to the way I proposed it.  I feel
very strongly about the specific example that Jesse L. provided above.  I want
to write some code and see what it looks like...


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