> along the lines of what Mark-Jason Dominus said some time ago about
> requiring a few declarations in exchange for not requiring all of
> them.

I like it. I thought about this some more too, though, and I fear it
doesn't have any benefits, beyond making things slower. After all, if
you're just going to go outward until you find the outermost one, what
advantage over no-scope dynamic globals does this have?

I think lexical variables are cool. But I think the more correct method
is to do the scoping in the reverse from what you mentioned. Declare
them at the outermost block (whole script, for ex), unless there's a
my(), in which case the method is the same as currently (explicitly
scope them to nearest block).

>   This behavior will, in almost all cases, work exactly the same as
> dynamic variables.

Yeah, that's the conclusion I came too as well. One benefit is other
people can't mess with your variables, though, and I think this is
definitely worth noting.

I'm not against this, I just think the scoping should be the reverse: 

   1. Outermost block lexicals by default

   2. Explicitly scope to nearest block with my() or our()

   3. If want dynamic, use "global", "dynamic", or some
      other keyword explicitly. Hey, I kinda like "your()".

If a person wanted different scoping rules beyond this, they could "use
scope 'subs'" (RFC 64), for example. For backwards compat, we could add
"use scope 'dynamic'" in which case it was Perl 5 all over again. :-)

-Nate

Reply via email to