<div class="gmail_quote">On Thu, Jul 26, 2012 at 11:01 AM, Dennis Lee Bieber <span dir="ltr"><<a href="mailto:wlfraed@ix.netcom.com" target="_blank">wlfraed@ix.netcom.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

On Thu, 26 Jul 2012 19:42:11 +1000, Chris Angelico <<a href="mailto:rosuav@gmail.com">rosuav@gmail.com</a>><br>
declaimed the following in gmane.comp.python.general:<br>
<div class="im"><br>
<br>
> Well, if/while/for could be functions. So could with, probably. Now,<br>
> def would be a little tricky...<br>
><br>
</div>        And how would a function "if" perform<br>
<br>
        if(conditional):<br>
would become<br>
        True:<br>
or<br>
        False:<br>
<br>
        What determines that branching is desired? The colon? (then what<br>
does the colon on "def x():" perform?)<br>
<br>
        Or take "while"...<br>
<br>
        while condition: #implies a loop<br>
<br>
        while(condition): #as a function implies a return value so again we<br>
have<br>
<br>
        True:<br>
or<br>
        False:<br>
<br>
        Now, how does the language differentiate between a loop and an if?<br></blockquote><div><br></div><div>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.</div>

<div><br></div><div>Now, the real problem comes in how to write those functions - they require themselves to be defined to be functional...</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<br>
        if(conditional):<br>
                do something and continue with next statement<br>
<br>
turns into<br>
        True:<br>
                do something and continue with next statement<br>
<br>
while<br>
<br>
        while(conditional):<br>
                do something and go back to the test<br>
<br>
turns into<br>
        True:<br>
                do something and go back to the test<br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
<br>
--<br>
        Wulfraed                 Dennis Lee Bieber         AF6VN<br>
        <a href="mailto:wlfraed@ix.netcom.com">wlfraed@ix.netcom.com</a>    <a href="HTTP://wlfraed.home.netcom.com/" target="_blank">HTTP://wlfraed.home.netcom.com/</a><br>
<br>
--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</font></span></blockquote></div><br>