What is the use/advantage of function overloading?

IMO, the primary benefit is consistency in the naming of methods / functions which logically perform very similar tasks, and differ slightly in by accepting different parameters. This allows the same method name to be reused across multiple implementations. e.g. The overloads: (Good) function Person[] FindPersons(string nameOfPerson) { … } function Person[] FindPersons(date dateOfBirth) { … Read more

Why would a language NOT use Short-circuit evaluation?

Reasons NOT to use short-circuit evaluation: Because it will behave differently and produce different results if your functions, property Gets or operator methods have side-effects. And this may conflict with: A) Language Standards, B) previous versions of your language, or C) the default assumptions of your languages typical users. These are the reasons that VB … Read more

Code Golf: Conway’s Game of Life

Mathematica – 179 163 154 151 chars a = {2, 2, 2}; s = Export[“out.txt”, CellularAutomaton[{224, {2, {a, {2, 1, 2}, a}}, {1,1}}, (ReadList[#1, Byte, RecordLists → 2>1] – 46)/ 42, #2]〚#2〛 /. {0 → “.”, 1 → “X”}, “Table”] & Spaces added for readability Invoke with s[“c:\life.txt”, 100] Animation: You can also get a … Read more