tag:blogger.com,1999:blog-8699431508730375743.post5909934651334026902..comments2016-07-20T07:15:28.987-07:00Comments on The History of Python: Origins of Python's "Functional" FeaturesGuido van Rossumhttp://www.blogger.com/profile/12821714508588242516noreply@blogger.comBlogger21125tag:blogger.com,1999:blog-8699431508730375743.post-38463159939780125552013-12-01T20:27:04.763-08:002013-12-01T20:27:04.763-08:00Hi, Guido :-) Misc/HISTORY records that lambda et...Hi, Guido :-) Misc/HISTORY records that lambda et alia were introduced in Python release 1.0.0 (26 January 1994), and that the code was contributed my Amrit Prem.Unknownhttps://www.blogger.com/profile/15023674227978538137noreply@blogger.comtag:blogger.com,1999:blog-8699431508730375743.post-59983159902174769062009-07-06T08:52:52.078-07:002009-07-06T08:52:52.078-07:00Guido: one thing that blew up for me was returning...Guido: one thing that blew up for me was returning functions. This is confirmed at <br /><br /> http://enthusiasm.cozy.org/archives/2005/04/original-closuresAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-8699431508730375743.post-52737113965541006532009-05-24T11:55:18.922-07:002009-05-24T11:55:18.922-07:00Neville, this probably doesn't belong in this comm...Neville, this probably doesn't belong in this comment thread any more, but I'm not sure I understand. Are you saying that the Algol68 example doesn't work? Can you mail guido@python.org so we can sort this out a bit more efficiently than in a comment thread? (I don't have an a68 compiler handy to experiment, sorry. :-)Guido van Rossumhttps://www.blogger.com/profile/12821714508588242516noreply@blogger.comtag:blogger.com,1999:blog-8699431508730375743.post-7028293299238920232009-05-24T05:03:41.952-07:002009-05-24T05:03:41.952-07:00re: Closures - Compare Python to Algol 68...
# Pyt...re: Closures - Compare Python to Algol 68...<br /># Python #<br />from math import *<br />root = lambda x: lambda y: exp(log(y)/x);<br />square_root = root(2); cube_root = root(3);<br />print square_root(64), cube_root(64)<br /># Algol 68 #<br />MODE F = PROC(REAL)REAL;<br />PROC root = (REAL x)F: (REAL y)REAL: exp(ln(y)/x);<br />F square root = root(2), cube root = root(3);<br />print((square root(64), cube root(64), new line))<br />Output: 8.0 4.0<br /><br />The key point about scoping is that with Algol 68 each argument "x" exists only on the LOC stack. Hence when "root" returns "x" becomes out of scope (off the stack). In python each "x" is in HEAP, then "follows" square_root and cube_root until these functions are no longer referenced.<br /><br />Quick fix for Algol 68 could be to put x on the HEAP eg.<br />PROC root = (HEAP REAL x)F: (REAL y)REAL: exp(ln(y)/x);<br />And let the garbage collector sort out x's closure.<br /><br />Minor other differences: Algol 68 is "IMPLICIT NONE", (useful for picking up bugs prior to runtime).NevilleDNZhttps://www.blogger.com/profile/11067569438021395601noreply@blogger.comtag:blogger.com,1999:blog-8699431508730375743.post-12507378830537764542009-05-19T06:56:00.000-07:002009-05-19T06:56:00.000-07:00@reinierpost: really? No closures in Algol 68? Wha...@reinierpost: really? No closures in Algol 68? What's your definition of closures? I'm pretty sure functions can reference variables in outer scopes, and functon objects can be passed around. What's missing for "closures"?Guido van Rossumhttps://www.blogger.com/profile/12821714508588242516noreply@blogger.comtag:blogger.com,1999:blog-8699431508730375743.post-90600254651326251372009-05-19T02:13:00.000-07:002009-05-19T02:13:00.000-07:00Perhaps it's worth pointing out that Algol 68 has ...Perhaps it's worth pointing out that Algol 68 has anonymous functions (but no closures).Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8699431508730375743.post-89936739623424436432009-04-26T02:53:00.000-07:002009-04-26T02:53:00.000-07:00How appropriate that the anonymous function patch ...How appropriate that the anonymous function patch is itself anonymous.Anonymoushttps://www.blogger.com/profile/13739788199470046447noreply@blogger.comtag:blogger.com,1999:blog-8699431508730375743.post-36174307130544518072009-04-22T13:57:00.000-07:002009-04-22T13:57:00.000-07:00New blog post in response to the tail recursion di...New blog post in response to the tail recursion discussion: http://neopythonic.blogspot.com/2009/04/tail-recursion-elimination.htmlGuido van Rossumhttps://www.blogger.com/profile/12821714508588242516noreply@blogger.comtag:blogger.com,1999:blog-8699431508730375743.post-52919320899527826402009-04-22T06:52:00.000-07:002009-04-22T06:52:00.000-07:00@Alex could you be a bit more specific. Evaling a ...@Alex could you be a bit more specific. Evaling a 'def ...' or a 'module.thing = lambda ...' won't change a function definition, it will provide a new function definition that might be bound to the same name. I don't know enough Python internals to know how much the actual byte code of a function can be changed (I had been assuming those are immutable, same as string contents).Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8699431508730375743.post-43643601926026805472009-04-22T05:17:00.000-07:002009-04-22T05:17:00.000-07:00I don't see why Python's dynamic nature would make...I don't see why Python's dynamic nature would make it impossible to do TCO, after all Erlang can do it and it is just as dynamic.Robert Virdinghttps://www.blogger.com/profile/16187415127098159771noreply@blogger.comtag:blogger.com,1999:blog-8699431508730375743.post-5919108588867350752009-04-22T03:40:00.000-07:002009-04-22T03:40:00.000-07:00you article is very interesting for meyou article is very interesting for meAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-8699431508730375743.post-48294818123873551882009-04-22T01:26:00.000-07:002009-04-22T01:26:00.000-07:00Seems like this is the TCO week for Python. Two bl...Seems like this is the TCO week for Python. Two blog posts that discussed this topic were published independently about the same time on Monday. This is now the third one.<br /><br />http://www.teamrubber.com/blog/python-tail-optimisation-using-byteplay/<br />http://fiber-space.de/wordpress/?p=349Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8699431508730375743.post-22700192186282605822009-04-21T20:05:00.000-07:002009-04-21T20:05:00.000-07:00Lua manages to have Tail-Call Optimization in a dy...Lua manages to have Tail-Call Optimization in a dynamic language, though I honestly don't know how much I'd use it.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8699431508730375743.post-20527554511581549602009-04-21T16:20:00.000-07:002009-04-21T16:20:00.000-07:00I hate that Python doesn't have Tail-Call Optimiza...I hate that Python doesn't have Tail-Call Optimization, though it does have the best stack traces of any language I've seen, which mostly makes up for it.<br /><br />Not being able to cleverly recurse isn't so bad when you never have to deal with anonymous "you tried to get the head of an empty list" exceptions!Fred Blasdelhttps://www.blogger.com/profile/08057528812732998703noreply@blogger.comtag:blogger.com,1999:blog-8699431508730375743.post-91620385810054564472009-04-21T12:16:00.000-07:002009-04-21T12:16:00.000-07:00You think Python could detect tail recusion, until...You think Python could detect tail recusion, until you find out someone monkey patched your function into something else in a different thread my eval'ing an opaque string.Alexhttps://www.blogger.com/profile/14054821112394577330noreply@blogger.comtag:blogger.com,1999:blog-8699431508730375743.post-47774828292367953002009-04-21T12:11:00.001-07:002009-04-21T12:11:00.001-07:00but? missing indentation in examples?but? missing indentation in examples?Juhanhttps://www.blogger.com/profile/07466683261343797955noreply@blogger.comtag:blogger.com,1999:blog-8699431508730375743.post-89297831835588521542009-04-21T12:11:00.000-07:002009-04-21T12:11:00.000-07:00You could fix the whitespaces in CSS:
blockquote ...You could fix the whitespaces in CSS:<br /><br />blockquote {<br /> white-space: pre;<br />}Anonymoushttps://www.blogger.com/profile/12732454351811400017noreply@blogger.comtag:blogger.com,1999:blog-8699431508730375743.post-88841035725517450652009-04-21T12:07:00.000-07:002009-04-21T12:07:00.000-07:00Argh. Fixed the whitespace.
Regarding tail optimi...Argh. Fixed the whitespace.<br /><br />Regarding tail optimization: that's a long topic, maybe I'll get to it in a future post on my other blog.Guido van Rossumhttps://www.blogger.com/profile/12821714508588242516noreply@blogger.comtag:blogger.com,1999:blog-8699431508730375743.post-54183983092996733752009-04-21T11:56:00.000-07:002009-04-21T11:56:00.000-07:00it's a shame that blogspot (at the time of this wr...it's a shame that blogspot (at the time of this writing) does not preserve the whitespace indentation that's necessary for Python code. :Pwescpyhttps://www.blogger.com/profile/08896306361304265422noreply@blogger.comtag:blogger.com,1999:blog-8699431508730375743.post-83982780510841561142009-04-21T11:55:00.000-07:002009-04-21T11:55:00.000-07:00Really, Python is so dynamic that it can't tell wh...Really, Python is so dynamic that it can't tell when 'return' is returning a function call and thus can't do tail-call optimization?<br /><br />Or is it unneeded/undesirable for some particular philosophical reason? (I am not familiar with all the stackless vs. core Python issues, so maybe that could make a future post, how the philosophies involved are incompatible)...<br /><br />Thank you for writing all of this down, it is a lot more important than it might seem at the time...<br /><br />-DougAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-8699431508730375743.post-79017868314013548112009-04-21T11:44:00.000-07:002009-04-21T11:44:00.000-07:00back to python now. miss its functions :Dback to python now. miss its functions :DCeyhunhttps://www.blogger.com/profile/12056513458669321101noreply@blogger.com