Pass-by-reference : Could a C#-like approach work in Python?

Terry Reedy tjreedy at udel.edu
Thu Sep 11 20:46:06 EDT 2003


"Stephen Horne" <$$$$$$$$$$$$$$$$$@$$$$$$$$$$$$$$$$$$$$.co.uk> wrote
in message news:uo02mv0dugi9ijk0k3llar0g3nmtnm59m6 at 4ax.com...
> On Thu, 11 Sep 2003 16:44:28 -0400, "Terry Reedy" <tjreedy at udel.edu>
> wrote:
>
> >realize that 'ref x' would have to have much the same effect of
Lisp's
> >FEXPR defun keyword -- of automatically quoting rather than
evaluating
> >args -- although on just one rather than all.  Perhaps you should
be
> >accused of 'trying to Lispify Python' -- or perhaps not ;-).
>
> I didn't know Lisp could do that.

Based on my reading of Winston&Horn's LISP (1st ed, 1981, MacLisp
based), auto quoting is the key to how Lisp conveniently turns
statements into syntactic functions.  Example:

Python statement: a=b # a is *not* evaluated but used literally
Python function: set('a',b) # requires explicit quote to not eval a
       where, for instance, def set(nam,val): globals()[nam]=val

Lisp s-expression 1: (set 'a b) # call is like Python function
Lisp s-expression 2: (setq a b) # where setq is an FEXPR-type function
that evaluates b but uses a literally, like Python statement

Autoquoting is also used for macro manipulation of code.

>I have to read up on Common Lisp one of these days.

LISP, 3rd ed, 1989, still in print, uses standard Common Lisp.
Chapter 12 Macros and Backquote might be of interest to you.

Terry J. Reedy






More information about the Python-list mailing list