from future import pass_function

Chris Kaynor ckaynor at zindagigames.com
Thu Jul 26 14:38:47 EDT 2012


On Thu, Jul 26, 2012 at 11: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
>
>         if(conditional):
> would become
>         True:
> or
>         False:
>
>         What determines that branching is desired? The colon? (then what
> does the colon on "def x():" perform?)
>
>         Or take "while"...
>
>         while condition: #implies a loop
>
>         while(condition): #as a function implies a return value so again we
> have
>
>         True:
> or
>         False:
>
>         Now, how does the language differentiate between a loop and an if?
>

Easy, the colon specifies a magic argument to the function which is the
executable block. In this way, the if function takes in a conditional,
then, based on whether the conditional is true, executes the code block or
not. A while loop is the same, but it just executes the block multiple
times. Additionally, the function's closure is set to the current scope.

Now, the real problem comes in how to write those functions - they require
themselves to be defined to be functional...


>
>         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
>
>
>
> --
>         Wulfraed                 Dennis Lee Bieber         AF6VN
>         wlfraed at ix.netcom.com    HTTP://wlfraed.home.netcom.com/
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20120726/0440a288/attachment.html>


More information about the Python-list mailing list