Prototypes, Objects, Functions, etc.
As I said previously, I really like prototype based languages. In those languages, an object if a hashtable with a link to a prent object (for empty slots).
An object can also be seen as a function explicitly defined which associates an object to an object. Moreover, this object has two more features: the value of a slot can be changed, and there is some kind of inheritence (the parent object).
Functions can be seen as extensions of objects.
Before going further, I'd like to clarify something: I will consider that there are no differences between objects and functions. Everything is an object, even functions. In order to do so, the definition of an object has to be extended: an object's slot are not constants, but patterns:
"foo" -> "bar"
| "bar" -> "baz"
| 42 -> "Doug'"
| n -> n+1
}
This object has two methods "foo" and "bar", a slot 42 whose value is "Doug" and a slot n which returns n+1 (with the convetion "plop"+1 = "plop1"). Moreover the method is called using the following syntax:
o.foo; // = "bar"
o 42; // = "Doug'"
o 41; // = 42
Thus when we write foo bar baz, we apply the object foo bar to the argumente baz. It's some kind of curryfication. Here is another cool example:
0|1 -> 1
| n -> this n = this (n-1) + this (n-2)
};
fibo 10;
fibo 20;
Fibo is well know, but here there is an implicit and automatic memoization, which is really awesome.
I have a few other ideas, but I'll keep them for another day ![]()