I guess this is not basic related, but this is the only fun forum there is for these kind of things so ...
I made a quick experiment with writing an interpreter for a new language in naalaa a while ago (
http://www.naalaa.com/community/showthread.php?tid=68). This resultet in a language that was way more "powerful" than naalaa itself. So I decided to rewrite it in C, and this is the result so far. At a first glance it may look like Lua but with C-like syntax, but ... it's not.
I'm not quite sure where I'm heading with this, but I've attached the sourcecode, you can build it with the makefile (on Linux). Sorry again about this not really being basic related.
There are some example programs included. Here's one about functions:
/*
* File: functions.txt
* -------------------
*/
/* Functions are assigned to variables using function. */
helloWorld = function() {
wln("Hello world!");
};
/* Call helloWorld. */
helloWorld();
/* Create a new function that takes two parameters and returns their sum. */
sum = function(a, b) {
return a + b;
};
wln(tostring(sum(3, 7)));
/* When calling a function, two reference variables are always created: this
and self. self can be used for object-based design and is explained in
another example. this is a reference to the function variable itself. */
countDown = function(n) {
wln(tostring(n));
if (n > 1) {
sleep(1000);
/* Make a recursive call through this. Actually we couldn't call
countDown for this purpose here, because functions can't normally
access variables from the main program. */
this(n - 1);
}
};
countDown(5);
/* If the function variable has sub-variables you can access those through
this. */
name.first = "John";
name.last = "Doe";
name = function() {
return this.first + " " + this.last;
};
wln(name());
One of the weirdest things with the language, compared to Lua and Javascript, is that a variable can have an intrinsic value and sub-variables at the same time. You can see that in the last part of the code above. The variable 'name' has two sub-variables (first and last), while its intrinsic value is a function that returns the two sub-variables combined.
I called the language prolan earlier, but now it's JAIL (just another interpreted language). I like stupid names.