loose spec for Script … EBNF to come

June 30th, 2006 by mike

Script 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;
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
Types vs References:
var integer = 5;
//Create a reference
ref var integer_r = 5;
print integer; //Dereference
print *integer_r;
Classes:
class abstract Matter {
protected var weight;
protected var volume;
virtual var getWeight(void);
virtual var getVolume(void);
}

class LifeForm extends Matter{
#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;
Function declarations:
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 |

2 Responses to “loose spec for Script … EBNF to come”

  1. David Sleight Says:

    I see you’ve made the switch to WordPress.

  2. mike Says:

    Indeed I have, it’s so much nicer than s9y and the output is xthml compliant. :-D

Leave a Reply