[racket] Boolean expressions [Was: static variables question]

From: Laurent (laurent.orseau at gmail.com)
Date: Sun Feb 19 04:14:56 EST 2012

On Sun, Feb 19, 2012 at 07:30, Gary Baumgartner <gfb at cs.toronto.edu> wrote:

> On Sat, Feb 18, 2012 at 09:02:41PM -0500, Stephen Bloch wrote:
> [...]
> > 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.
> >
> > if (blah == true) {
> >    return true;
> >    }
> > else {
> >   return false;
> >   }

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.
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).
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?)
The previous years I was not insisting so much on reduction of expressions,
and it was more difficult to make this notion clear.

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?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20120219/549eb357/attachment.html>

Posted on the users mailing list.