Re: Lambda: the Ultimate Design Flaw

2005-04-01 Thread Sunnan
Daniel Silva wrote:
We think dropping FILTER and MAP is pretty uncontroversial; (filter P
S) is almost always written clearer as a DO loop (plus the LAMBDA is
slower than the loop).  Even more so for (map F S).  In all cases,
writing the equivalent imperative program is clearly beneficial.
How about using srfi-42 instead of those nasty do loops?
It's pretty clean:
(list-ec (: a lis) (* a a))
is equivalent to
(map (lambda (a) (* a a)) lis)
Before I discovered srfi-42, my code often had hideous things like:
(append-map
 (lambda (item)
   (map
(lambda
(inner)
  (* inner inner))
   (cdr item)))
 lis)
to return (1 4 9 16 25 36 49 64 81) for
a lis that's '((a 1 2 3) (b 4 5 6) (c 7 8 9))).
This becomes even neater:
(list-ec
 (: item lis)
 (: inner (cdr item))
 (* inner inner))
Have a happy first of april!
--
http://mail.python.org/mailman/listinfo/python-list


Re: Lambda: the Ultimate Design Flaw

2005-04-01 Thread Sunnan
Jeremy Bowers wrote:
Yes and no. In the Python community, we're taking all of that pretty
seriously. The scheme community may not seriously be thinking of getting
rid of those things, but it's hardly impossible that some people think it
might be better off without it.
Lambda is a primitive in Scheme; in some implementations of scheme it's 
used to implement things like temporary variables (let), sequences 
(begin) and looping (named let/letrec).

Python has other ways of doing these things; and removing things that 
has been obsoleted or superfluous makes sense, for Pythons ideal of 
having one canonical, explicit way to program.

Having a few very abstract primitives that the rest of the language can 
theoretically be built upon is one of the reasons why Scheme/Lisp can 
work as a programmable programming language.

Scheme is like Go - a few abstract rules that can be combined in 
endless, sprawling ways.

Python is like (hmm, better let some pythonista answer this. I'm 
thinking of a game with a clear thematical connection (like Monopoly or 
The Creature that Ate Sheboygan) and a few explicit rules that combine 
in ways that is supposed to have a clear, readable, consistent result). 
Maybe shogi?

(I don't usually read comp.lang.python and I really don't want to offend 
anyone. My apologies if this post is either annoyingly obvious (and thus 
contains only stuff that's been said a million times), or totally wrong.)

Sunnan
--
http://mail.python.org/mailman/listinfo/python-list


boring the reader to death (wasRe: Lambda: the Ultimate Design Flaw

2005-04-01 Thread Sunnan
Aahz wrote:
"The joy of coding Python should be in seeing short, concise, readable
classes that express a lot of action in a small amount of clear code -- 
not in reams of trivial code that bores the reader to death."  --GvR
Can anyone please point me to the text that quote was taken from? I 
tried to use a search engine but I only found quotations, not the source.
Sunnan
--
http://mail.python.org/mailman/listinfo/python-list


Re: Ternary Operator in Python

2005-04-01 Thread Sunnan
Terry Reedy wrote:
Gee, what about 0.0 < a < 1.0 < b < 2.0?  I see both as synthesized 
multinary operators, but your are right in that this combination does act 
differently than a+b+c.
Is < really multinary in python? It looks binary to me, just like +.
(a+b)+c
(((0.0 < a) < 1.0) < b ) < 2.0
Sunnan
--
http://mail.python.org/mailman/listinfo/python-list


Re: Pseudocode in the wikipedia

2005-04-01 Thread Sunnan
James Stroud wrote:
bob == (carol = 2):
  if bob = (bob or carol):
bob == 4
But no one could figure out what bob was supposed to equal anyway.
Wouldn't bob equal the boolean result of the expression (carol = 2)?
--
http://mail.python.org/mailman/listinfo/python-list


Re: boring the reader to death (wasRe: Lambda: the Ultimate Design Flaw

2005-04-02 Thread Sunnan
Tim Peters wrote:
[Aahz]
"The joy of coding Python should be in seeing short, concise, readable
classes that express a lot of action in a small amount of clear code --
not in reams of trivial code that bores the reader to death."  --GvR

[Sunnan]
Can anyone please point me to the text that quote was taken from? I
tried to use a search engine but I only found quotations, not the source.

That's because it was originally in email to a company-internal
mailing list.  If you're willing to move to Fredericksburg, VA and
work for Zope Corp, perhaps they'll let you in to the PythonLabs list
archives.  Fair warning:  I work for Zope Corp, and I'm not sure I can
get into those archives.  So don't switch jobs _just_ for that.
It's just that I'm having a hard time matching that quote to what I 
though python was about. I thought boring code was considered a virtue 
in python. ("Explicit is better than implicit", "sparse is better than 
dense".)

Because what is "boring"? The opposite of dense, tense, intense. Utterly 
predictable; it's like the combination of all my prejudices. Even before 
I knew, I thought "Bet Python separates statements from expressions".

Sunnan
PS.
(People easily offended can substitute "boring" for "readable" in the 
above text.)
--
http://mail.python.org/mailman/listinfo/python-list


Re: Ternary Operator in Python

2005-04-02 Thread Sunnan
Robert Kern wrote:
Sunnan wrote:
(((0.0 < a) < 1.0) < b ) < 2.0

Go on. Try it with a bunch of different values.
My bad. (Of course. The subexpressions must return booleans, not the 
largest number. It couldn't work any other way.) Egg on my face, and all 
that (figuratively speaking).

Not used to infix...
--
http://mail.python.org/mailman/listinfo/python-list


Re: boring the reader to death (wasRe: Lambda: the Ultimate DesignFlaw

2005-04-03 Thread Sunnan
Scott David Daniels wrote:
No, poetry is to be read slowly and carefully, appreciating the nuance
at every point.  You should be able to read "past" python, while poetry
is at least as much about the form of the expression as it is about
what is being expressed.
Right, I agree with these descriptions of python vs "the poetry 
languages". I'm not sure whether I'd consider python particularly terse, 
though, but I don't know enough about it yet. (I've read a couple of 
programs but never started a project of my own in it, mainly because I 
love poetry. I can see the appeal of a "prose language", though.)
--
http://mail.python.org/mailman/listinfo/python-list


Re: boring the reader to death (wasRe: Lambda: the Ultimate Design Flaw

2005-04-03 Thread Sunnan
Aahz wrote:
Note very, VERY, *VERY* carefully that the quote says nothing about
"boring code".  The quote explicitly refers to "reams of trivial code"
as boring -- and that's quite true.  Consider this distinction:
Thank you for this important clarification.
if foo == 'red':
print 'foo is red'
elif foo == 'blue':
print 'foo is blue'
versus
print "foo is", foo
Is the space added automatically? (Like awk does, if you add a comma.)
I'm sure you can think of many other examples -- real examples -- if you
put your mind to work; Guido's point is about the essential necessity of
refactoring and rewriting code for conciseness and clarity.
Which is a good point to make in almost any language, for code that is 
to be maintained.

Sunnan
--
http://mail.python.org/mailman/listinfo/python-list


Re: Lambda: the Ultimate Design Flaw

2005-04-03 Thread Sunnan
Artie Gold wrote:
Torsten Bronger wrote:
The whole text seems to be a variant of
.
TschÃ,
Torsten.
Ya think? ;-)
Heh. I was glad that Torsten pointed it out; I didn't get what was funny 
about the joke until then.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Lambda: the Ultimate Design Flaw

2005-04-05 Thread Sunnan
T.D. Lassagne wrote:
Please consider joining the International Sarcasm Society.  Our motto is 
"Like We Need YOUR Support". 
I *recognize* sarcasm; I just don't think it's very funny. Now parody, 
which this turned out to be, I can appreciate.
--
http://mail.python.org/mailman/listinfo/python-list


Re: boring the reader to death (wasRe: Lambda: the Ultimate DesignFlaw

2005-04-06 Thread Sunnan
Ville Vainio wrote:
Read up on list comprehensions and generator expressions. You'll see
the terse side of Python (and genexps look kinda poetic too ;-).
I am familiar with lc:s/genexps, I usually program in scheme which also 
has them (srfi-42).
They're very nice and I use them a lot.
--
http://mail.python.org/mailman/listinfo/python-list


Re: boring the reader to death (wasRe: Lambda: the Ultimate Design Flaw

2005-04-06 Thread Sunnan
Ville Vainio wrote:
Boring code is code that numbs your senses with constant flow of
boilerplate crap, memory management and redundant type declarations
and general blah blah that you skip when you are trying to figure out
what a piece of code does.
The python code I've read so far has looked like that. Not type 
declarations, but lng class declarations.

Also, Guido recently urged people to explicitly write recursions rather 
than to use reduce - which I thought was completely in line with what 
I've seen as python's goals: readability/understandability as more 
important than terseness/non-boringness.

> It's a code that you wish you could train a
monkey to write for you while you go for lunch. Think C++ or Java.
Oh, yes. C++ and Java can be super boring. C++ can also be pretty hard 
to understand - it's not all boilerplate.

I'm not saying Python is always boring (maybe I've just been in an 
easily bored mood when I've read Python stuff), and I'm not saying that 
boring is always bad.

Yesterday, I read some marketing prop describing a proprietary IDE 
(don't remember what language) as "exciting", and I went "Ugh, no 
thanks! Give me calm computing." And then I thought - wait: I just 
ranted about boringness on comp.lang.python. Can't boring and calm 
sometimes mean the same thing?
--
http://mail.python.org/mailman/listinfo/python-list