mmk

Sing along with S

Sep 01, 2008 10:16

Singing with my nephew, I realized that internally I was having a lot of discomfort with this line: (where I was processing "you" is an instance of the Human class, i.e. Human *)

If( you->Are(Human::HAPPY) && you->Know(Human::HAPPY) )
{

you->Clap(Human::HANDS) ; } How is it possible for the first condition to be true and the second to be false ( Read more... )

Leave a comment

Comments 6

bluesmoon September 2 2008, 04:20:33 UTC
You have a logical error in your code. It should be this:

if( you->are(Human::HAPPY) && you->know(you->state == Human::HAPPY) )
{
you->Clap(you->HANDS);
}

Knowledge of happiness is required for the first condition. Knowledge of self is required for the second condition.

Also note that I've rescoped HANDS, since they are instance members.

Reply

Good serious point mmk September 3 2008, 02:37:49 UTC
Knowledge of self is good point. So is the rescoping of HANDS. However, just for completeness, I'd do:

(you->are(Human::HAPPY) && you->know(you, Human::HAPPY))

As you could use the same interface to know the state of others as well, nu?

Reply

Re: Good serious point bluesmoon September 3 2008, 02:58:20 UTC
Agreed. The bigger flaw in my code is that you->state == Human::HAPPY is boolean, so Human::know() would have to take in a boolean value, which doesn't make sense. Knowing truth from lies doesn't say anything about knowledge of self or happiness.

Reply


Aaargh! sankalpa September 4 2008, 06:24:07 UTC
And the geeks shall inherit the Earth...

Why don't you write-out the Indian national anthem in multi-threaded C++ code?

Reply

Re: Aaargh! mmk September 23 2008, 19:50:01 UTC
Heh, it was already written in Bangla, a far superior multi threaded language.

Reply


muttering_ogre September 23 2008, 03:47:00 UTC
You might easily be too busy to notice that you're happy.

Reply


Leave a comment

Up