develooper Front page | perl.perl5.porters | Postings from November 2013

Re: [perl #119791] [PATCH] Remove support for "do SUBROUTINE(LIST)"

Thread Previous | Thread Next
Ricardo Signes
November 9, 2013 03:13
Re: [perl #119791] [PATCH] Remove support for "do SUBROUTINE(LIST)"
Message ID:
* Father Chrysostomos via RT <> [2013-11-08T20:55:13]
> Also, do we want do foo() to have its logical behaviour of passing the return
> value of foo to do-file?  Or should it be a syntax error?
> (The latter is the type of question we should always ask when removing a
> feature.)

Right now, the situation is already lousy:

  ~$ perl -Mwarnings -e 'sub z { return 0 } do z()'
  Use of "do" to call subroutines is deprecated at -e line 1.

  ~$ perl -Mwarnings -e 'sub x { return 0 } do x()'

My assumption has always been that the 'x' operator is interfering.

Anyway, I think we're better off simply eliminating the special case of `do
SUB(LIST)`, meaning it would fall back to EXPR.  On the other hand, I think
this is where the question of backcompat will come in.

If there's code with `do foo($x)` out in the wild, and it becomes equivalent to
`do(do { foo($X) })`, something stupid is going to happen somewhere.  I imagine
we may be doing the world a favor by inserting a period of fatality.


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