"The fact that this expression evaluates to<br>true after the waiting time is what confuses me, compared to traditional<br>programing language control structures."<br><br>I've been following this thread and now I'm also very curious
<br>to know the answer here. It's one thing to call for a delay<br>in the main loop, but quite another to add a delay as condition. <br><br>- fadereu<br><br><div class="gmail_quote">On Nov 11, 2007 7:34 AM, Juan-Pablo Caceres <
<a href="mailto:jcaceres@ccrma.stanford.edu">jcaceres@ccrma.stanford.edu</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="Ih2E3d">
Martin Ahnelöv wrote:<br>> lör 2007-11-10 klockan 09:29 -0800 skrev Juan-Pablo Caceres:<br>>> Hi there,<br>>><br>>> I have another question concerning time logic. The following 2 examples<br>>> are similar:
<br>>><br>>> // 1)<br>>> while (true)<br>>> {<br>>> <<<"HELLO">>>;<br>>> 1::second => now;<br>>> }<br>>><br>>> // 2)<br>>> while (1::second => now)
<br>>> {<br>>> <<<"HELLO">>>;<br>>> }<br>>><br>>><br>>> So the question is, is the second case using some syntactic sugar?<br>>> Because conceptually it doesn't sound right to me. Maybe the chuck gurus
<br>>> out there can make more sense of it?<br>>><br>><br>> Well, it's pretty easy, actually. While takes an expression, and if that<br>> expression returns true, it evaluates the code inside the brackets, and
<br>> then it tests the expression again. This expression can be anything from<br>> "true", to "i<100", or even a function (that can do absolutely<br>> anything). in the second case it's "1::second=>now", which will return
<br>> true when 1 second have passed.<br><br></div>Hi Gastern,<br><br>I understand how 'while' works on programming languages. What confuses<br>me in chuck is the meaning of the expression<br>(dur => now)<br>
<br>A 'while(expression)' cycle will stop executing the statement as soon as<br>the expression evaluates to 'false'. In the case of evaluating (dur =><br>now), I think that there's also a timing logic involved, in the sense
<br>that if (1::second => now) evaluates to 'true' only when 1 second has<br>passed, it should evaluate to false in every other time, which would<br>cause the control to exit the block.<br><br>What (I think) is going on is that (dur => now) as an expression is just
<br>waiting, advancing time, and as soon as time has advances 'dur', it<br>evaluates to true by default. The fact that this expression evaluates to<br>true after the waiting time is what confuses me, compared to traditional
<br>programing language control structures.<br><br>Sorry for the lengthy and confusing email!<br>JPa.<br><div><div></div><div class="Wj3C7c"><br><br>_______________________________________________<br>chuck-users mailing list
<br><a href="mailto:chuck-users@lists.cs.princeton.edu">chuck-users@lists.cs.princeton.edu</a><br><a href="https://lists.cs.princeton.edu/mailman/listinfo/chuck-users" target="_blank">https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
</a><br></div></div></blockquote></div><br><br clear="all"><br>-- <br>------- -.-<br>1/f ))) --.<br>------- ...<br><a href="http://www.algomantra.com">http://www.algomantra.com</a>