The Dummy-In-Chief

I had to implement another class for debugging: ExpressionElement. It’s just a container class without any methods. The Java class is:

class ExpressionElement
{
 public int token;
 public double value;  
 public int nesting;

 public ExpressionElement(int new_token, 
  double new_value, int new_nesting)
 {
  token = new_token;
  value = new_value;
  nesting = new_nesting;
 }
}

And my first version in JavaScript was (using a bit of JSDoc syntax):

/**
 * @class lg3dExpressionElement
 * @classdesc A container class for elements  
 * (i.e., nodes) of symbolic expressions. 
 *
 * @desc Create a new lg3dExpressionElement object.
 */
function lg3dExpressionElement(new_token, new_value, new_nesting)
{
 token = new_token;
 value = new_value;
 nesting = new_nesting; 
}

The problem is that in JavaScript, I have to write “this.token”, “this.value”, and “this.nesting” instead of “token”, “value”, and “nesting”. Interestingly, I wasn’t able to debug the code in FireFox and had difficulties with Chrome. The worst part was that for more than an hour, I suspected that the problem was the WLAN connection and/or a FireFox update.

On the positive side, I’ve probably learned an important lesson for the rest of my life (or at least a few weeks).

Martin