I'm intrigued that Python has some functional constructions in the language.

namekuseijin namekuseijin.nospam at gmail.com
Sun May 10 15:40:50 EDT 2009


Carl Banks wrote:
> On May 9, 10:57 am, namekuseijin <namekuseijin.nos... at gmail.com>
> wrote:
>> Carl Banks wrote:
>>> On May 8, 7:19 pm, namekuseijin <namekusei... at gmail.com> wrote:
>>>> On May 8, 10:13 pm, Carl Banks <pavlovevide... at gmail.com> wrote:
>>>> In Haskell, Lisp and other functional programming languages, any extra
>>>> syntax gets converted into the core lambda constructs.
>>> So?  The user still uses that syntax, so how can you claim it doesn't
>>> matter?
>>>>  In Lisp
>>>> languages, that syntax is merely user-defined macros, but in Haskell
>>>> it's builtin the compiler for convenience.
>>> I don't even know what you're saying here
>> I'm saying syntax is nothing special.  They are user-defined, as
>> functions.  And it all gets converted into functions.  Functions matter,
>> syntax is irrelevant because you can do away with it.
> 
> Nope, sorry, you're ignoring half the problem here.  Syntax is only
> irrelevant if you actually do do away with it.  As long as syntax is
> there and people use it, then it matters, regardless of whether it all
> reduces to function calls.

It's handy, yes.  It's just nothing special, specially when composing 
programs out of function composition.

> For a very benign example, consider the ways that Python and Haskell
> write listcomps:
> 
> [ x for x in ss ]
> [ x | x <- ss ]
> 
> One of these might be more readable than the other (I make no
> implication which);

Haskell uses math notation, which may not be to everyone's tastes as far 
as IT has largely left its compsci and math roots and every Joe Sixpack 
might assembly an usable app with a scripting language, some 
template-writing IDE and a few frameworks.

> however, readability has nothing to do with
> whether the compiler internally reduces it to a function call or not.
> Readibility counts, therefore syntax matters.

Function calls are perfectly readable.

> Now, maybe readability concerns don't matter to you personally, but it
> does matter to the OP, who is trying to advocate functional
> programming but is having difficulty because most purely functional
> languages have hideous minimalist syntax that turns people off.

BTW, rereading it again, the OP was originally questioning about 
compiler optimizations for purely functional constructs within Python, 
but somehow syntax got in the middle.

I don't see how "syntax would be a lot easier to understand" if it would 
"be possible to more clearly separate the pure code (without side 
effects) from the impure code (that deals with state changes, I/O, 
etc.), so that the pure code could be compiled and have aggressive 
functional transformations applied to it for efficiency."

Syntax would remain the same, I guess.

>> In functional programming languages, predefined syntax is mostly
>> irrelevant.  In Python and other imperative languages, it's absolutely
>> necessary.  That's my point.
> 
> I think you are overstating this by a lot.

Perhaps.



More information about the Python-list mailing list