develooper Front page | perl.perl5.porters | Postings from April 2003

Alter behaviour of local($x = ...)?

Thread Next
Dave Mitchell
April 22, 2003 13:51
Alter behaviour of local($x = ...)?
Message ID:
Currently, the expression

    local($x = 'bar')

acts identically to

    $x = 'bar'

ie, nothing gets localised or restored. Eg see bugid #1778 (*).

This is because the OPpLVAL_INTRO flag is set on the assign op, and
neither pp_sassign nor pp_aassign take any notice of this flag.

The options seem to be:

1) leave things as they are

2) make local($x = ...) generate a compile-time warning like
    "local() on an assignment is ignored"
(better suggestions for the wording wecome)

3) Make localisation happen.
If so, is it semanticly equivalent to
    3a) local($x); $x=...;
    3b) $x=...; local($x);

Personally, my vote is for (2).

Opinions, anyone?


(*) yes, I'm so bored that I'm trawling through the bugs DB looking for
easy entertainment.

But Pity stayed his hand. "It's a pity I've run out of bullets",
he thought. - "Bored of the Rings"

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