The Inside Track on Firefox Development.

« Feed Content Now Visible | Main | I Hate Comcast »

May 8, 2006

Code for the Wise

var demo = new Hotness();
if (manager)
  demo.fail();
else
  demo.run();
Patch by fitz:
--- demo-rules.js	2006-05-08 09:59:46.775999400 -0700
+++ demo-rules.js	2006-05-08 10:00:12.809415200 -0700
@@ -1,4 +1,4 @@
-if (manager)
+if (manager && !sacrificeMadeToDemoGods)
   demo.fail();

Posted by ben at May 8, 2006 8:58 AM

Comments

Heh :)
Is this internal Google code?

Posted by: Martijn at May 8, 2006 9:17 AM

You haven't defined Hotness. That code is bad! :-P

Posted by: Philip Withnall at May 8, 2006 11:44 AM

Looks like the patch is wrong. Should it be || instead of && ? Or maybe I'm missing something?

Posted by: Ciaran at May 8, 2006 12:50 PM

"Should it be || instead of && ?"

Well if the demo has already been sacrificed, I guess it doesn't matter if you try to run it since it doesn't exist anymore. :b

Unless trying to run a sacrified demo causes an error. O_O Maybe somebody should file a bug to be safe.

Posted by: herorev at May 8, 2006 6:23 PM

It does not say that the DEMO was sacrificed, it says that A sacrifice has been made. Its saying that it will only run the demo for a manager if you have made a sacrifice to the gods. So && makes perfect sense.

Posted by: Charlie Hayes at May 9, 2006 10:56 PM

actually, it should be ||.
demo.fail() executes when (manager && !sacrificeMadeToDemoGods) is true. for that condition to be true, since it is &&, both manager and !sacrificeMadeToDemoGods must be true simultanesouly. which means, both the presence of a manager and a lack of sacrifice is required for the demo to fail. which means, the demo could still run fine(demo.run()) if one of those is true as long as the other is false.

since this is pressumedly commentary about the apparent fragility of demonstration code, you would think that for the demo to *run*(avoid failure), BOTH the manager must not be looking and the coder must have made the proper sacrifice. therefore, the relevent patch line should be:

+if (manager || !sacrificeMadeToDemoGods)

now, if the manager is present, or if the coder failed to make the sacrifice, the demo will fail. for the demo to run successfully, BOTH of those things will have to be dealt with.

you should probably revoke fitz's cvs access.

Posted by: sineral at May 14, 2006 8:34 PM

Greetings ,
excuse me but its an odd way to communicate ...i sent you an email yesterday ..hope it didn't end up in your spam box

Posted by: geoaxis at May 20, 2006 1:16 PM

nice blog keep it up ! good luck

Posted by: Buy Fragrance at June 2, 2006 8:59 PM

Instead of making useless posts you could try to fix the mess that Firefox's memory management is.

Oh wait, I forgot memory hogging is a feature, not a bug...

Posted by: Henk Tiggelaar at June 6, 2006 4:08 AM

And what do you display on failure? :)

Posted by: Michael at June 8, 2006 8:51 AM