Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
While Dominus is in part right that the discussion on perl6-language-strict could have been more productive, there are indeed issues that make this less than easy to do.

I'm working on a paper for this, so I don't want to give everything away early, but the basic upshot is that there are three languages often mentioned in the same breath as Perl that do make variables lexical by default, each in different ways. And, as you might imagine, each of them has their own problems.

Python has only two real scopes -- global and nearest-enclosing-block lexical. If Perl went this way, we would lose a *lot* of flexibility.

Ruby does a better job with scopes, but it is very easy to create action-at-a-distance problems. I.e. you write a function that has a tightly enclosed lexical scope. A year later, you add a variable 300 lines above it that happens to have the same name as a variable in that tight lexical scope, and all of the sudden the two variables are the same -- you've inadvertently changed the scope of a lexical.

Tcl gives the most flexibility of the three, but you end up with all kinds of `upvar' nonsense to try and place variables in the scopes you want them. Easy to screw up and also very verbose.

In sum, there are possibly better ways to do it than the way Perl does it now, but figuring out the semantics that are best is far from easy.

I hope to finish my paper sometime soon, and if people are interested I'll post it here for comments before I make it public. It will hopefully be able to suggest a reasonable semantic for Perl 6.

-dlc


In reply to Re: Default Scope Behaviour by dchetlin
in thread Default Scope Behaviour by NeoPerl

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-04-25 06:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found