<br><br><div class="gmail_quote">On Sun, Feb 19, 2012 at 07:30, Gary Baumgartner <span dir="ltr"><<a href="mailto:gfb@cs.toronto.edu" target="_blank">gfb@cs.toronto.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Sat, Feb 18, 2012 at 09:02:41PM -0500, Stephen Bloch wrote:<br>
[...]<br>
> I see a lot of my students doing this -- in whatever language -- because they think of Booleans as a way to decide which of two things to DO, rather than as legitimate values in their own right. In fact, the whole world of expressions is a bit of a foreign country -- a sort of "adjunct" to the more-legitimate world of statements.<br>
><br>
> if (blah == true) {<br>
> return true;<br>
> }<br>
> else {<br>
> return false;<br>
> }<br></blockquote><div><br></div><div>I too see this quite often (teaching PHP to non - CS/math freshmen, using === instead of == and trying to put types wherever possible), and it seems it's because I tell them something like "the first arm of the if is executed if the test is true, otherwise the other arm is executed". So they want to have a comparison operator in the test.</div>
<div>But this year I insisted more on expressions and reduction to a resulting type and value, and when I see a student doing that I only need to tell him/her "In fact the first arm is executed if the resulting value of the test is the value /true/, and the other arm is executed if the resulting value is the value /false/" and s/he seem to be enlightened (sometimes it is still needed to say that the "=== true" part can thus be removed, but s/he then seem to understand and agree).</div>
<div>But I couldn't manage to make sure they understand this directly in the first place, and it seems that many students still need to go through the first notion (which might be simpler at first) and then go to the better definition. (Or I am doing things wrong?)</div>
<div>The previous years I was not insisting so much on reduction of expressions, and it was more difficult to make this notion clear.</div><div><br></div><div>Laurent</div><div>P.S. : It's great to know that other teachers have the same problems teaching programming languages. Is there a mailing list where such matters are discussed?</div>
<div><br></div><div><br></div><div> </div></div>