Sorry for being quiet for a while.
I decided I wanted to experiment with writing an interpreter for a programming language in naalaa, just for fun. It quickly got out of control and is now a mix of C, naalaa and LUA. You can easily do OOP style programming in it.
I will rewrite and develop this further in C and see if something useful pops out. But if you want to have a look at the naalaa code, I've attached it to this post. There are a couple of example programs included in a folder named "tests". Open prolan.nala/prolan.txt in NED and modify a line at the beginning of the source code to change which program to run:
Here's one of the example programs that demonstrates OOP-style programming:
I'm a bit amazed I could make this work as a naalaa program, haha
I decided I wanted to experiment with writing an interpreter for a programming language in naalaa, just for fun. It quickly got out of control and is now a mix of C, naalaa and LUA. You can easily do OOP style programming in it.
I will rewrite and develop this further in C and see if something useful pops out. But if you want to have a look at the naalaa code, I've attached it to this post. There are a couple of example programs included in a folder named "tests". Open prolan.nala/prolan.txt in NED and modify a line at the beginning of the source code to change which program to run:
Code:
' Change this to functions.txt, loops.txt, oop.txt, variables2.txt or
' variables.txt.
FILENAME$ "variables.txt"
Here's one of the example programs that demonstrates OOP-style programming:
Code:
Person = function(firstName, lastName, age) {
p.firstName = firstName;
p.lastName = lastName;
p.age = age;
p.setFirstName = function(name) {
self.firstName = name;
};
p.setLastName = function(name) {
self.lastName = name;
};
p.setAge = function(age) {
self.age = age;
};
p.getFirstName = function() {
return self.firstName;
};
p.getLastName = function() {
return self.lastName;
};
p.getName = function() {
return self.firstName + " " + self.lastName;
};
p.getAge = function() {
return self.age;
};
p.tostring = function() {
return self.getName() + " (" + tostring(self.age) + ")";
};
return alias(p);
};
ListPersons = function(alias list) {
for (p: list) {
wln(p.tostring());
}
};
ListPersonsUsingGlobal = function() {
for (p: persons) {
wln(p.tostring());
}
};
wln("Creating 4 identical persons");
for (i = 1, 4) {
persons[i] == Person("John", "Doe", 40);
}
ListPersons(persons);
wln("");
wln("Changing two of them");
persons[1].setFirstName("Marcus");
persons[1].setLastName("Johansson");
persons[1].setAge(39);
p = alias(persons[2]);
p.setFirstName("Frank");
p.setLastName("Foulbottom");
p.setAge(56);
unalias(p);
visible persons;
ListPersonsUsingGlobal();
I'm a bit amazed I could make this work as a naalaa program, haha
