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 : 16. Mar 2024, 09:27:57
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <ut3hlt$2pi20$1@dont-email.me>
References : 1 2 3 4
User-Agent : Pan/0.155 (Kherson; fc5a80b8)
On Sat, 16 Mar 2024 00:46:21 -0600, Jeff Barnett wrote:

First off, I believe that many if not most exception-related primitives
expand in terms of dynamic variables.

Consider the following Python example:

    class MyException1(Exception) :
        pass
    #end MyException1

    class MyException2(Exception) :
        pass
    #end MyException2

    def func1() :
        raise MyException1
    #end func1

    def func2() :
        raise MyException2
    #end func2

    def func3() :
        class MyException1(Exception) :
            pass
        #end MyException1

        try :
            func1()
        except MyException1 :
            # will never get here
            print("caught MyException1 in func3")
        #end try
    #end func3

    def func4() :
        try :
            func2()
        except MyException2 :
            print("caught MyException2 in func4")
        #end try
    #end func4

    for f in (func1, func2, func3, func4) :
        try :
            print("* call %s" % f.__name__)
            f()
        except MyException1 :
            print("caught MyException1 at top level")
        except MyException2 :
            print("caught MyException2 at top level")
        #end try
    #end for

Here is the output it produces:

    * call func1
    caught MyException1 at top level
    * call func2
    caught MyException2 at top level
    * call func3
    caught MyException1 at top level
    * call func4
    caught MyException2 in func4

func4 shows how the search for a handler is based on dynamic execution
nesting. func3 shows how exception matching is based on lexical
scoping.

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