Origin of eval()-ing in separate namespace object

Discussion in 'Python' started by Kalinni Gorzkis, Dec 8, 2013.

  1. By which languages(s) Python was inspired to support evaluating expressions and executing statements in a separate “namespace” object?

    This syntax:
    eval(expression,globals) or exec(code,globals)
    What is the origin of the functionality provided by the globals argument?
     
    Kalinni Gorzkis, Dec 8, 2013
    #1
    1. Advertising

  2. Kalinni Gorzkis

    rusi Guest

    On Sunday, December 8, 2013 4:05:54 PM UTC+5:30, Kalinni Gorzkis wrote:
    > By which languages(s) Python was inspired to support evaluating expressions and executing statements in a separate “namespace” object?


    > This syntax:
    > eval(expression,globals) or exec(code,globals)
    > What is the origin of the functionality provided by the globals argument?


    Been here since the days of scheme at least
    http://docs.racket-lang.org/guide/eval.html#(part._namespaces)

    For the record lisp was conceptualized in the late 50s and implemented
    by 1960. By the 80s it was widely regarded as the premier AI language
    but it was also clear to users that the scoping rules were terribly
    wrong. So a number of the then lisps coalesced and re-separated into
    2 major dialects -- scheme and common lisp.

    I expect it -- 2 argument eval -- goes all the way back to the earliest lisp
    but Ive not access to the history.
     
    rusi, Dec 8, 2013
    #2
    1. Advertising

  3. rusi writes:

    > On Sunday, December 8, 2013 4:05:54 PM UTC+5:30, Kalinni Gorzkis wrote:
    >
    > > By which languages(s) Python was inspired to support evaluating
    > > expressions and executing statements in a separate "namespace"
    > > object?

    >
    > > This syntax:
    > > eval(expression,globals) or exec(code,globals)
    > > What is the origin of the functionality provided by the globals
    > > argument?

    >
    > Been here since the days of scheme at least
    > http://docs.racket-lang.org/guide/eval.html#(part._namespaces)
    >
    > For the record lisp was conceptualized in the late 50s and
    > implemented by 1960. By the 80s it was widely regarded as the
    > premier AI language but it was also clear to users that the scoping
    > rules were terribly wrong. So a number of the then lisps coalesced
    > and re-separated into 2 major dialects -- scheme and common lisp.
    >
    > I expect it -- 2 argument eval -- goes all the way back to the
    > earliest lisp but Ive not access to the history.


    Yes. From p. 13 of LISP 1.5 Programmer's Manual (the preface is dated
    in 1962):

    # _evalquote_ is defined by using two main functions, called _eval_
    # and _apply_. _apply_ handles a function and its arguments, while
    # _eval_ handles forms. Each of these functions also has another
    # argument that is used as an association list for storing the values
    # of bound variables and function names.

    That association list is the namespace. _eval_ and _apply_ pass it
    around and extend it as they call each other to evalute code.

    So it seems that at least the idea of an explicit namespace argument
    was there from the start. Mistakes related to the original dynamic
    scoping continued to be made.
     
    Jussi Piitulainen, Dec 8, 2013
    #3
  4. Kalinni Gorzkis

    rusi Guest

    On Sunday, December 8, 2013 8:09:39 PM UTC+5:30, Jussi Piitulainen wrote:
    > rusi writes:


    > > On Sunday, December 8, 2013 4:05:54 PM UTC+5:30, Kalinni Gorzkis wrote:
    > > > By which languages(s) Python was inspired to support evaluating
    > > > expressions and executing statements in a separate "namespace"
    > > > object?
    > > > This syntax:
    > > > eval(expression,globals) or exec(code,globals)
    > > > What is the origin of the functionality provided by the globals
    > > > argument?

    > > Been here since the days of scheme at least
    > > http://docs.racket-lang.org/guide/eval.html#(part._namespaces)
    > > For the record lisp was conceptualized in the late 50s and
    > > implemented by 1960. By the 80s it was widely regarded as the
    > > premier AI language but it was also clear to users that the scoping
    > > rules were terribly wrong. So a number of the then lisps coalesced
    > > and re-separated into 2 major dialects -- scheme and common lisp.
    > > I expect it -- 2 argument eval -- goes all the way back to the
    > > earliest lisp but Ive not access to the history.


    > Yes. From p. 13 of LISP 1.5 Programmer's Manual (the preface is dated
    > in 1962):


    > # _evalquote_ is defined by using two main functions, called _eval_
    > # and _apply_. _apply_ handles a function and its arguments, while
    > # _eval_ handles forms. Each of these functions also has another
    > # argument that is used as an association list for storing the values
    > # of bound variables and function names.


    Heh – I am nostalgia-fied!

    Wrote a Lisp interpreter as a student degree project in 1986.
    Tried to use the Lisp 1.5 manual then but it was too archaic for me to
    understand. So mostly chewed on the UCI Lisp manual. Took me some
    years to understand that dynamic scoping was not my mistake but Lisp's!!
     
    rusi, Dec 8, 2013
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Eric Newton
    Replies:
    3
    Views:
    9,601
    Brock Allen
    Apr 4, 2005
  2. EvgueniB
    Replies:
    1
    Views:
    671
    Anthony Borla
    Dec 15, 2003
  3. Frank Fredstone
    Replies:
    1
    Views:
    466
    Jean-Francois Briere
    Jun 27, 2006
  4. Chris Hall

    exceptions and eval'ing a string

    Chris Hall, Sep 19, 2007, in forum: Ruby
    Replies:
    3
    Views:
    127
    Robert Klemme
    Sep 19, 2007
  5. bernd
    Replies:
    2
    Views:
    689
    bernd
    Jan 26, 2012
Loading...

Share This Page