The end to all language wars and the great unity API to come!

rantingrick rantingrick at gmail.com
Wed Jul 6 17:33:46 CEST 2011


On Jul 6, 9:55 am, Steven D'Aprano <steve
+comp.lang.pyt... at pearwood.info> wrote:
> rantingrick wrote:
> > -------------------------------------------
> > THIS CODE RESULTS IN A CONTROL STRUCTURE!
>
> > --> lst.sort(lambda x,y: cmp(x[1], y[1]))
>
> No it doesn't.
>
> How does it change the program flow? You call the sort method, it sorts, and
> execution continues at the next statement. Regardless of whether you supply
> a cmp function or not, the program flow is identical:

Not identical. The sort called WITHOUT a cmp argument will sort in a
predefined manner. The sort called WITH a cmp argument can modify the
existing code block in a way that suits a users desired result. A USER
DEFINED CONTROL STRUCTURE. Just because this realization breaks the
mold of everything you hold dear about user defined control structures
does not mean it is incorrect. For some reason you are religious about
this subject. Could it be that you are wrong?

> ENTER SORT ROUTINE
> PERFORM SORTING
> EXIT SORT ROUTINE

True for the non-modified case.

False for the modified one...

 ENTER SORT ROUTINE
 PERFORM SORTING BASED ON USER DEFINED CONTROL
 EXIT SORT ROUTINE

> There is no control transferred. It is a linear program flow: in, do the
> job, out again. Since it doesn't modify the program flow, it is not a
> control structure.

So you are telling me that calling cmp(itemsA[idx], itemsB[idx]) is
exactly the same as cmp(itemsA[idx][-1], itemsB[idx[-1])? Please show
proof of this in code. You have just witnessed the power of user
defined control structures and it has rocked your little world. You
believed UDCS to be evil, all the while oblivious to your own everyday
usage of them. Now that's ironic. Cruel or poetic, you be the judge.

> "Perform sorting" is a black box. It could have loops, branches,
> unconditional exists. It could have COMEFROM statements up the wazoo, if it
> were implemented in a language with COMEFROM (like Intercal). None of that
> matters two bits: the caller cannot use sort to modify the execution
> sequence around it, therefore it's not a control structure. No matter how
> much the sort routine jumps around internally, you can't use that change
> program flow around it.

The "jumping"(sic) around is controlled by a user defined spec. The
user is in control. The user made the definition. The cmp function
just implemented it.

> print surely is implemented with a loop: it has to loop over a string and
> write it to stdout. Would you say that therefore print is a control
> structure:
>
> ENTER PRINT STATEMENT
> PERFORM PRINTING
> EXIT PRINT STATEMENT

Nope. Print only takes an argument and spits out the result to
stdout.write. Print is an abstraction API for system.stdout.write, and
nothing more.

> One entry, one exit.
As evident from all the BS you spew on a daily basis, apparently YOU
have one entry and one exit!




More information about the Python-list mailing list