There are some problems with the whitespace in Python.
List comprehensions is another example -- a kludge coming from that the lack of multi instruction lambdas stop real map functions. (The fun part is that this necessity is touted as something good, instead of admitting that it is unnecessary complexity to learn.)
I've used both Perl and Python. When using Perl I use anonymous functions all the time. When writing Python, I don't. There are instances where in Perl I would use an anonymous function, but in Python I define a local function an pass the reference. Each language has it's own style.
If you're trying to fight the language's style, then you will obviously run into friction. I'm sure there are plenty of people coming from C/C++/Java that think that dynamically-typed languages are unusable because type can't be enforced at 'compile time.' Defining an anonymous function vs. a one-time use local function is mostly a matter of style/preference.
| which of course was an ugly pain to port to Python with
| no multi-line lambdas
There are two things you are describing here:
1) It was a pain to name all of these anonymous blocks.
2) The idea of naming the blocks is annoying / aesthetically displeasing to you.
#1 is just part of porting something between different languages. You would equally run into issues porting JS and/or Ruby code to Haskell, even with support to lambdas. #2 is just personal opinion / preference, even if it's one that shared by many.
| (The fun part is that this necessity is touted as
| something good, instead of admitting that it is
| unnecessary complexity to learn.
I could use the same argument to rail against statically-typed languages. "A type system is just unnecessary complexity to learn."
 I welcome examples of where anonymous functions are unable to be replaced by local functions passed by reference.
Uh... different paradigms. The scripting languages, which we are talking about here, are generally very similar.
>> I welcome examples of where anonymous functions are unable to be replaced by local functions passed by reference.
Where did I write "unable" -- did I disprove some Turing machine theorem and forget about it? :-)
In this specific case it was a declarative data structure with some data next to code. It was well suited to have a dozen or two short functions next to the data structures.
You could rethink the whole thing and do something different in Python to keep it readable. But among the normal languages (in the same paradigm), Python is the odd man out, just because of the lack of multi line lambdas.
(I also gave the example of bad influences on map, etc.)
| >>Ruby code to Haskell
| Uh... different paradigms. The scripting
| languages, which we are talking about here,
| are generally very similar.
Different languages are different, no matter how
many similarities that they have. You are going
to run into issues porting between languages.
Expecting anything else is setting yourself up for
C++ and ObjC are both 'C-based', so there should
be zero issues porting code between them, right?
French and Spanish are both Latin-based, so they
are practically the same language, right?
| >> I welcome examples of where anonymous
| >> functions are unable to be replaced by
| >> local functions passed by reference.
| Where did I write "unable" -- did I disprove
| some Turing machine theorem and forget about it?
Poorly worded on my part.
| In this specific case it was a declarative
| data structure with some data next to code. It
| was well suited to have a dozen or two short
| functions next to the data structures.
| You could rethink the whole thing and do
| something different in Python to keep it
| readable. But among the normal languages (in
| the same paradigm), Python is the odd man out,
| just because of the lack of multi line lambdas.
1. The inclusion of multi-line lambdas in a
language is what makes it 'normal'? This just
seems more like a personal opinion than anything
objective. I could easily say that Ruby is the
odd-man out and Perl/Python are the 'normal'
languages, because of this:
a = 0
puts "Evaluates to True"
Or Perl is the odd-man-out and Ruby/Python are the
'normal' languages because they have a GIL.
2. If keeping the data structure and functions
together was the best use-case, then maybe Python
wasn't the tool for the job. Just like I wouldn't
talk about how crappy Ruby is because it doesn't
>>The inclusion of multi-line lambdas in a language is what makes it 'normal'?
All the scripting languages are very, very similar (see data structures, etc).
In short, you don't argue against my point.
My point was that Python stops multi-line lambdas for some weird purity argument re white spaces (I haven't found any other motivation).
This hurts quite a few use cases (for a 2nd -- copy paste and automatic indentation of code is at least more complex, and so on) and makes it necessary to learn weird syntax (list comprehensions), which incidentally is touted as the next coming of Christ...
And the inability to admit a wart on Python is quite typical -- didn't Guido tell you guys to stop trolling recently, because you were getting bad reputation..?
>> Or Perl is the odd-man-out and Ruby/Python are the 'normal' languages because they have a GIL.
These three are all similar -- avoid threading. :-(
Not that it is relevant for my original point, either.
> These three are all similar -- avoid threading. :-(
Perl gets a bad rep on threading because it's threads don't map to what many people consider the strong points of threads, which is light weight processes. Perl fails spectacularly in that regard, but if you want multi-process programming with a standard, well understood set of primitives for IPC, it's really quite nice. That is, the 'threads' module isn't all that great by itself, but when paired with 'threads::shared', it's really quite nice (as long as you are pre-spawning workers or don't require quick thread spawning).
For example, I love how locks are scope based, which makes the following possible:
> There are some problems with the whitespace in Python.
As nnq points out elsewhere in this thread, this doesn't have anything to do with significant whitespace. Python only allows you to have a single expression in the body of a lambda, and from what I've read the reason it stays this way is to discourage using a lambda as an argument to map, fold, filter & friends. The usual suggestion from Python programmers is to just use a locally defined, named function, which to be honest is often what I do anyway in languages like ML, because it's clearer.
And anyway, just because it was hard to port some code from language A to language B due to something different about B doesn't really seem like a valid knock against B.
My argument was that a lack of real anonymous functions (> 1 instruction) is a problem in some quite common and useful scenarios.
If you REALLY can give good references that show this is wrong, I'm very interested (like, I would guess, most Ruby users).
(It would also be interesting with a link to a PEP or something with, as you claim, arguments that map etc should be discouraged -- and that is why no multi line lambdas exists. For instance, how would the syntax look like??)
My argument was just that it has nothing to do with significant whitespace, which is what you were complaining about. Python could be changed to have non-significant whitespace but retain its crippled lambda.
You made specific claims (regarding map recommendations in Python and that white space has nothing to do with one instruction lambdas). I asked for references. I assume you have none?
Note that with significant white space a usable syntax for multi-instruction lambdas seems... non-trivial. It seems to me as an unusually stupid fan boy position. But a few well argued references, which you lack, would change my mind. I'm no troll.
Edit: I might also note that your reference nng is a low-Karma account that argues that a cometing open source language to his love child is dead -- typical language war troll. Is that your only reference?
I should rest all this rip, but I can't help it: reference to multi-line lambdas in languages with Python-like syntax: http://cobra-language.com/trac/cobra/wiki/AnonMethod, http://boo.codehaus.org/Closures (yep, you're right, having multiple closures on a single line with offsite-rule syntax is "non-trivial" and no one solved this yet, but even one per line would be enough to make map and fold bearable, and ftr, I want to punch Guido or whoever else has a saying in language's design for not "stealing" this and adopting it into Python - I think there was a PEP along the lines that got killed and burried, can't find it now).
You asked about multi-line lambdas in python and I gave you a valid Python syntax for multi-line anonymous functions. Here is PEP 202, which simply says list comprehensions are more concise than for loops and map/filter etc.
Considering the way Python people have been trolling most every Perl discussion for the last few years when I've been on HN, I feel like I'm in orbit compared to people in the mud...
I might also note that I got two non sequitur answers in a row, so a joke like that is imho not an extreme reaction. Hardly as sarcastic as you was over a joke, at least...
Edit: I might also note that this article (76 votes) is 5 places below another roughly equally old article (8 hours) with 13 votes. So it is probably flagged to Hell. I do feel classy, compared to some others.