Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #55411

Re: Tail recursion to while iteration in 2 easy steps

From random832@fastmail.us
Subject Re: Tail recursion to while iteration in 2 easy steps
Date 2013-10-03 10:09 -0400
References <l2feu0$n61$1@ger.gmane.org> <1380717085.6985.29063445.6AD889D5@webmail.messagingengine.com> <l2i3f7$v4o$1@ger.gmane.org>
Newsgroups comp.lang.python
Message-ID <mailman.676.1380809370.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Wed, Oct 2, 2013, at 17:33, Terry Reedy wrote:
> 5. Conversion of apparent recursion to iteration assumes that the 
> function really is intended to be recursive.  This assumption is the 
> basis for replacing the recursive call with assignment and an implied 
> internal goto. The programmer can determine that this semantic change is 
> correct; the compiler should not assume that. (Because of Python's late 
> name-binding semantics, recursive *intent* is better expressed in Python 
> with iterative syntax than function call syntax. )

Speaking of assumptions, I would almost say that we should make the
assumption that operators (other than the __i family, and
setitem/setattr/etc) are not intended to have visible side effects. This
would open a _huge_ field of potential optimizations - including that
this would no longer be a semantic change (since relying on one of the
operators being allowed to change the binding of fact would no longer be
guaranteed).

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: Tail recursion to while iteration in 2 easy steps random832@fastmail.us - 2013-10-03 10:09 -0400
  Re: Tail recursion to while iteration in 2 easy steps Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-10-04 02:05 +0000

csiph-web