Not in any meaningful sense of the term.
LOL
Yes. In a functional language that wouldn't be a problem, as there's no
limit to the complexity of an expression. Python's expressions are far
more limited, which restricts what can be done with a lambda.
One very annoying thing in Python is the distinction between
statements and expressions.
Ever since learning LISP (well, Scheme) in S&ICP I find myself
frequently annoyed by this pointless distinction, started by
C (or earlier), and propogated without much thought.
Often I'll want to write a lamda that, say, prints something, or
modifies a global variable, and find that, well, it's either
impossible or beyond my interest in figuring it out.
It appears there is finally a ternary operator (for making if/else
into "expressions"):
http://en.wikipedia.org/wiki/Ternary_operation#Python
Maybe it will grow on me - it makes sense in English, but on
first glance I thought the programmer suffered from dyslexia.
To be fair, it appears that Python's whitespace-sensitive syntax sort
of precludes the "make a complex function on one line" that is typical
of languages which don't have statement/expression distinctions, but
I'm not convinced it couldn't be solved, perhaps by allowing anonymous
functions to span multiple lines, just like named functions.
Not really. List comprehensions are probably the most common example of
functional idioms, but again they're limited by Python's rather limited
concept of an expression.
Map/reduce, lambda, apply, that kind of stuff... kinda similar to
functional languages.
But "statements lack any side effects"? No way.
In fact, a common distinction you'll see observed, but not always, is
that "statements may have side effects, expressions do not".
For some definitions of "functional language", there are no
side-effects, so there is no need for a statement which doesn't
evaluate to a value, so there is no need for a statement/expression
distinction, so everything is an expression.
You may have seen Paul Graham's other article about Python and LISP:
http://www.paulgraham.com/icad.html
Upon re-skimming it, I find myself wondering if I got the
expression/statement annoyance from his pages, or from my own
experience. I can't remember
Probably it was an annoyance that I
hadn't put my finger on until he spelled it out for me, like a
splinter in my mind
He obliquely references my other pet peeve, the global/class/local
distinction, completely ignoring arbitrarily-nested lexical scoping.
From what I've read in this thread, there's a recent "nonlocal"
declaration that sounds like it might accomplish something useful in
this regard.
(I still haven't figured out how he managed to use lexical closures in
his web server to allow one web page to use another to allow the user
to select and return a value, like a color from a color wheel, unless
he implemented his own web server in LISP, since HTTP is stateless).
I really like Scheme's clean syntax (never learned Common LISP, sorry,
too much to remember) but frankly, I've never looked at a problem and
said, "you know, Scheme would be perfect for this". Maybe if I was
writing a program that did optimizing transformations on abstract
syntax trees, or something. And since Scheme has never come in handy,
I never bothered with Common LISP. I feel similarly about ML, OCAML
and Haskell... maybe one day when I'm bored, not today, not this
project.
So in the end, I find myself using python more than anything else,
fully acknowledging its warts. I used to admire its simplicity, but
now with decorators, iterators, generators, metaclasses, and the
proliferation of special method names, I have to wonder if that still
holds true... certainly I understand 90+% of python programs, but
do I understand that proportion of the constructs?
PS: Why do people call LISP object-oriented? Are they smoking crack?
No classes, no methods, no member variables... WTF?
--
A Weapon of Mass Construction
My emails do not have attachments; it's a digital signature that your mail
program doesn't understand. |
http://www.subspacefield.org/~travis/
If you are a spammer, please email (e-mail address removed) to get blacklisted.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (OpenBSD)
iQIcBAEBAgAGBQJL7s7oAAoJEGQVZZEDJt9H7XYP/jHR6da87mD8LJXTz7S27B+x
zGCBCs3z7GluHiuuas9N1ur7E7mKLki0SnXtr760aooWEOadEA/WKLiBIbP3HNfS
X3AcV7rsZrTHz3Lmuhj6/ctdiUIQepEZe2rUQ79SR+3i3kMkIR+rdTRKL0lRMGVv
hy5GImlB++x+E1LLOVPr5zuqfUOtX94pHBTjOqg/iKQhc9F3J5MDoPrbF11uZhdV
HFM9/Zg4ulshqF15oI6iqhS1/QCCFA/BimZ0tkN/DG3Q7q142wTUB6wDd3iX548h
ZbvZi2bXn2GhZWMiToAe3kIZLqyZ45Pf4pqzCRQhD+j7scrOMiLiwMw2C2HxWeEJ
1U6xNhUHpgxgtzbphExep/iiceyOoQmPo46FnpvvZpPIN7bEkEBbn0iw5xU0ZOTw
4tqFruw44YmyDyhT/wkX3WTtzsaDygidLycNltnztfBT7wLC5VWcQRfrZU9yGVxg
28CPiQbfWRniMd+wXSISrH4zEvVSVpfc3pVH0+ROLjE5m0578PxKTTr3zeIqmtKV
tZzIs4hXxOX5fWQKTcXiWIwlh0SF5ZaA2+w/+eTwtN5KSlziWcPHEo4BFlEUI3yf
+Uwg9tRtZfvJfVekGphmO+gnxWmVywBoJ2YnoI2817QjM0XIXajp2nqtBQVSjEf+
0nbGYcfIi93ADOxw7bQH
=ha/9
-----END PGP SIGNATURE-----