Re: History of lexical scope in Lisp

Liste des GroupesRevenir à cl lisp 
Sujet : Re: History of lexical scope in Lisp
De : ldo (at) *nospam* nz.invalid (Lawrence D'Oliveiro)
Groupes : comp.lang.lisp
Date : 19. Mar 2024, 07:44:55
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <utb8on$lttb$1@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10
User-Agent : Pan/0.155 (Kherson; fc5a80b8)
On Mon, 18 Mar 2024 23:02:23 -0600, Jeff Barnett wrote:

... you really can't escape from one dynamic scope to
another.

Au contraire, with dynamic scoping, such “escaping” happens all the time.

Here’s an example from a language, namely Perl, which does allow for
dynamic scoping (in fact, early on it had no lexical scoping):

    $a = 1;

    sub f1()
      {
        $a = $a + 1;
      } # f1

    sub f2()
      {
        local $a = 3;
        print "inner ", $a, "\n";
        f1();
        print "inner ", $a, "\n";
      } # f2

    f1();
    print "outer ", $a, "\n";
    f2();
    print "outer ", $a, "\n";
    f1();
    print "outer ", $a, "\n";

The output is

    outer 2
    inner 3
    inner 4
    outer 2
    outer 3

I didn’t say error handling was lexically based, I said the matching of
exceptions was lexically based. I thought my example made that
distinction clear.
 
Maybe it did but not to me.

Look back again, and see how the outer exception is not the same as the
one with the same name local to the function, yet the catch clauses search
for the exceptions according to dynamic execution nesting.

Want me to go over it step-by-step?

Date Sujet#  Auteur
15 Mar 24 * History of lexical scope in Lisp23Paul Rubin
16 Mar 24 +* Re: History of lexical scope in Lisp14Jeff Barnett
16 Mar 24 i`* Re: History of lexical scope in Lisp13Lawrence D'Oliveiro
16 Mar 24 i +- Re: History of lexical scope in Lisp1Kaz Kylheku
16 Mar 24 i `* Re: History of lexical scope in Lisp11Jeff Barnett
16 Mar 24 i  +* Re: History of lexical scope in Lisp9Lawrence D'Oliveiro
17 Mar 24 i  i`* Re: History of lexical scope in Lisp8Jeff Barnett
17 Mar 24 i  i `* Re: History of lexical scope in Lisp7Lawrence D'Oliveiro
18 Mar 24 i  i  `* Re: History of lexical scope in Lisp6Jeff Barnett
18 Mar 24 i  i   +* Re: History of lexical scope in Lisp3Lawrence D'Oliveiro
19 Mar 24 i  i   i`* Re: History of lexical scope in Lisp2Jeff Barnett
19 Mar 24 i  i   i `- Re: History of lexical scope in Lisp1Lawrence D'Oliveiro
18 Mar 24 i  i   +- Re: History of lexical scope in Lisp1Lawrence D'Oliveiro
19 Mar 24 i  i   `- Re: History of lexical scope in Lisp1George Neuner
16 Mar 24 i  `- Re: History of lexical scope in Lisp1Kaz Kylheku
16 Mar 24 +* Re: History of lexical scope in Lisp4Robert Brown
16 Mar 24 i`* Re: History of lexical scope in Lisp3Lawrence D'Oliveiro
16 Mar 24 i `* Re: History of lexical scope in Lisp2Robert Brown
16 Mar 24 i  `- Re: History of lexical scope in Lisp1Lawrence D'Oliveiro
16 Mar 24 +- Re: History of lexical scope in Lisp1Kaz Kylheku
17 Mar 24 +* Re: History of lexical scope in Lisp2Didier Verna
17 Mar 24 i`- Re: History of lexical scope in Lisp1Lawrence D'Oliveiro
19 Mar 24 `- Re: History of lexical scope in Lisp1Johanne Fairchild

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal