loose spec for Script … EBNF to come
June 30th, 2006 by mikeScript will be a compiled, object-oriented, semi-strongly-typed web scripting language. What I mean by semi-strongly-typed is that there is a set size allocated by the compiler at compile time to hold the data associated with a variable. In (32bit intel) c-like style, 4 bytes will be allocated to hold all primitive types. Other types will be objects internally stored as pointers. There will be only one primitive data type.
Note in the below that “var” is simply a placeholder as I haven’t decided what to call the primitive declaration just yet. It could as easily be int, char, etc. Any suggestions ?
var x = 5; Types vs References:
x = 'a';
x = 0xfffffff8;
x = 48h; x = 07551; // Correct
String y = "foo";
y.append("bar");
print y;// foobar
// Incorrect
String y = "foo";
y = "foobar";
// buffer overflow -- won't compile
var integer = 5; Classes:
//Create a reference
ref var integer_r = 5;
print integer; //Dereference
print *integer_r;
class abstract Matter {
protected var weight;
protected var volume;
virtual var getWeight(void);
virtual var getVolume(void);
}
class LifeForm extends Matter{ Function declarations:
#enum TYPE "Carbon", "Silicon";
TYPE type;
public ref LifeForm(TYPE t = "Carbon") {
this.type = t; return this;
}
var getWeight(void) {
return this.weight;
}
var getVolume(void) {
return this.volume;
}
}
LifeForm person = new LifeForm();
print person; // prints 0xDEADBEEF;
var multiply(var x, var y) {
return x * y;
}
String append(String a, String b) {
return a.append(b);
}
ref factorial(var x) {
return ref (*factorial(x - 1)) * x;
}
Posted in NextPL |
July 20th, 2006 at 3:40 am
I see you’ve made the switch to WordPress.
July 20th, 2006 at 3:39 pm
Indeed I have, it’s so much nicer than s9y and the output is xthml compliant.