from future import pass_function

Chris Angelico rosuav at gmail.com
Thu Jul 26 14:14:17 EDT 2012


On Fri, Jul 27, 2012 at 4:01 AM, Dennis Lee Bieber
<wlfraed at ix.netcom.com> wrote:
> On Thu, 26 Jul 2012 19:42:11 +1000, Chris Angelico <rosuav at gmail.com>
> declaimed the following in gmane.comp.python.general:
>
>> Well, if/while/for could be functions. So could with, probably. Now,
>> def would be a little tricky...
>>
>         And how would a function "if" perform

It'd be much more similar to the ternary operator. Currently there's
no way to pass an unevaluated expression to a Python function, but the
concept isn't impossible. It's just more suited to functional
languages (someone mentioned Haskell) than to imperative ones.

>         Now, how does the language differentiate between a loop and an if?
>
>         if(conditional):
>                 do something and continue with next statement
>
> turns into
>         True:
>                 do something and continue with next statement
>
> while
>
>         while(conditional):
>                 do something and go back to the test
>
> turns into
>         True:
>                 do something and go back to the test

Oh THAT's easily solved. A while loop is an if with a goto!

Okay, was that sufficiently incendiary? Have fun! :)

ChrisA



More information about the Python-list mailing list