I am programming a Lisp like language on JavaScript for learning purposes. Every object is part of a tree so it must keep track of its parent. The only problems are numbers and strings:
foo = {};
var a = 1;
a.parent = foo;
This will not work. I have to do this instead:
foo = {};
var a = {type:'number',value:1,parent:foo}
So I would have to box every number and string on my language in a hash like that. I pretend to do some extensive matrix math on said language, so I am worried. Would this approach be a hit on performance?
As Reid suggested:
Output:
This probably answers the question. I wonder if there is an alternative that won’t be such a performance hit.