All~

I can try, but most of what I say is just from memory of the Programming Languages class that I took... Thus I cannot guarantee perfect recall...

The place where we learned about this is in closures and functional languages. In a purely functional language one cannot assign to variables (as that would be a side-effect). So the question becomes how is binding done, lexically or dynamically. In lexical binding you look for the most closely nested variable of that name in the code. In dynamic binding you look for the most closely defined variable in the call stack. Thus one code snippet can produce to different values depending on the binding scheme:
bar(z) { return x+z; } baz(x) { return bar(2); }
In such code, bar will access the x from baz, if the language has dynamic scoping.

I was told that the way to think of this in a language with side-effects is that all variables can be thought of as global, since they all access the most recently referenced version. So what we have here is fluid scoping which causes changes to a variable not to propogate to the outside world, by causing them to revert at end of scope. This would happen automatically in a language without side-effects, because you cannot assign to a variable...

That is at least the way I understand it. I could be mistaken.

Boots
---
Computer science is merely the post-Turing decline of formal systems theory.
--???

In reply to Re: Re: Re: Re: Re: Why does Perl use dynamic scoping? by Boots111
in thread Why does Perl use dynamic scoping? by blokhead

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.