(and scheme lisp) x Python and modern langs [was Re: gossip, Guy Steel, Lojban, Racket]

Xah Lee xahlee at gmail.com
Tue Sep 28 19:56:55 CEST 2010


xah wrote:
> in anycase, how's “do” not imperative?

On Sep 28, 6:27 am, namekuseijin <namekusei... at gmail.com> wrote:
> > how's “do” a “named let”? can you show example or reference of that
> > proposal? (is it worthwhile?)
>
> I'll post it again in the hope you'll read this time:
>
> "
> (do ((i 0 (+ 1 i))  ; i initially 1, (+ 1 i) at each "step"
>      (r 0 (+ i r))) ; r initially 0, (+ i r) at each "step"
>   ((> i 5) r))      ; when i>5, return r
> => 15
>
> it's merely a macro (syntax) that gets transformed into this:
> (let loop ((i 0)
>            (r 0))
>   (if (> i 5) r
>     (loop (+ 1 i) (+ i r))))
> => 15
>
> which is merely a macro that essentially gets transformed into this:
> ((lambda (loop)
>    (loop loop 0 0))
>  (lambda (loop i r)
>    (if (> i 5) r
>        (loop loop (+ 1 i) (+ i r)))))
> => 15
>
> which, as you can see, is merely function application.  There's
> nothing there except evaluation of arguments, application of arguments
> to function and function return.  It's not because they chose `do', or
> `for' or `while' for naming such syntax, that it behaves the same as
> their imperative homographs."
>
> > as i said, regarding do: “do” in general in any lang is simply
> > impreative. We don't even have to know the details. I don't care
> > whatnot fuck proposal from whatnot lisp of what's actually going on.
> > If it is named “do”, it is imperative.
>
> It's not:  one can name factorial do.  It's just a name.  Who doesn't
> like do?  It's short, to the point...

ultimately, all lang gets transformed at the compiler level to become
machine instructions, which is imperative programing in the ultimate
sense.

You say that “do” is merely macro and ultimately function application.
But to what level should we go down this chain on how the language
actually works when evaluating a function in source code?

any functional lang, quickly becomes imperative when compiled to some
intermediate code or interpreted. In a sense, it can't be any other
way. Functions are abstract mathematical ideas, while “do” loop or any
instruction are actual steps of algorithms.

 Xah ∑ xahlee.org ☄



More information about the Python-list mailing list