Python's Lisp heritage
Paul Foley
see at below
Sat Apr 27 08:36:09 EDT 2002
On Thu, 25 Apr 2002 22:26:30 -0700, James J Besemer wrote:
> Paul Foley wrote:
>> No I don't have to admit that...I don't even have to admit that there
>> are any parentheses in Lisp :-)
> What color is the sky in your world? ;o)
> Seriously, I agree, the underlying abstraction -- the semantics -- does not require
> parentheses. But that's not really the language, per se.
I think you're missing the point: Lisp is not defined in terms of
text; instead, it's the objects that result from calling READ on that
text. There are no parentheses in that result; there are only lists,
symbols, strings, integers, etc., etc. That's why you can define
things like the infix syntax reader Jacek Generowicz mentioned.
READ can call arbitrary user-defined functions to parse the textual
representation into internal objects, so it can read any surface
syntax you want.
>> In any case, parentheses are not used around sub-expressions, or to
>> separate or group statements. They're only used (in evaluated
>> contexts) for "function" calls, and most other languages, including
>> Python, use parentheses for that purpose, too:
>>
>> Python: foo(x)
>> Lisp: (foo x)
>>
>> Same number of parentheses, right?
> Besides, this is an entirely contrived, intellectually dishonest example.
> First off, parens ARE used around sub expressions last I checked, unless I don't get how
> you define sub expression. E.g.,
> (foo (+ x (/ 1 n)))
> vs.
> foo( x + 1 / n ).
+ and / are just ordinary functions, in Lisp. If they were ordinary
functions in Python you'd have to write
foo(+(x,/(1,n)))
which, again, has the same number of parentheses. Functions are the
general case -- there are only a handful of infix operators in general
use, and you don't get to define new ones in Python anyway -- so I
don't think I'm being "intellectually dishonest".
When you talk about parenthesising subexpressions, I think of
something like
x + (1 / n)
requiring the parentheses; i.e., having to write
(+ x ((/ 1 n))) or perhaps even (+ (x) ((/ (1) (n))))
in Lisp (which aren't even legal in Lisp: you /can't/ parenthesise
subexpressions!)
--
In modern physics, the more logical you are, the more wrong you are.
-- Lama Govinda
(setq reply-to
(concatenate 'string "Paul Foley " "<mycroft" '(#\@) "actrix.gen.nz>"))
More information about the Python-list
mailing list