The purposes that they serve are not so different. In fact in many languages - including every version of Lisp before Scheme and Perl before my was introduced in Perl 5 - dynamic scope was routinely used for what we now tell people to use lexical scope for.

Admitted, there are differences. And there are times when you really do want dynamic scope. But those are few and far between. The times that I have used it are for locking logic (in which case straight dynamic scope does not do the job, I need the dynamic thing to be visible outside of my program) and once for a deep recursion test (you can use local on the values of a hash!). I could have survived without built-in dynamic scope for both cases, but would have had to use exception handlers to do it safely. (You need to catch every way of exiting the dynamic scope...)

As for the idea of having a ton of custom variables which can be accessed from anywhere that contains state, if your programs look like that then you probably could stand to learn something about good program design IMO. A multiplication of global or semi-global variables is a red flag for a bad design. (Geez, can I sound more arrogant?)


In reply to Re: Re: Implementing (elisp-like) buffers in Perl 6: how to do buffer-localisation of arbitrary package variables? by Anonymous Monk
in thread Implementing (elisp-like) buffers in Perl 6: how to do buffer-localisation of arbitrary package variables? by jonadab

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.