FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

August 15th - Sooo good

 
Post new topic   Reply to topic     Forum Index -> MiniD
View previous topic :: View next topic  
Author Message
JarrettBillingsley



Joined: 20 Jun 2006
Posts: 457
Location: Pennsylvania!

PostPosted: Tue Aug 15, 2006 10:27 pm    Post subject: August 15th - Sooo good Reply with quote

I worked a bunch of kinks out of the interpreter, and it seems to work quite nicely now. The following:

Code:
local function foo()
{
   writefln("hi ", 4, ", ", 5);
}

foo();

writefln();

local t =
{
   x = 5,
   y = 4.5,
   
   function foo(this)
   {
      writefln("foo: ", this.x, ", ", this.y);
   }
};

t:foo();

writefln();

local function outer()
{
   local x = 3;

   local function inner()
   {
      ++x;
      writefln("inner x: ", x);
   }

   writefln("outer x: ", x);
   inner();
   writefln("outer x: ", x);

   return inner;
}

local func = outer();
func();

writefln();

function arrayIterator(array, index)
{
   ++index;
   
   if(index >= #array)
      return null;

   return index, array[index];
}

function pairs(container)
{
   return arrayIterator, container, -1;
}

local arr = [3, 5, 7];

foreach(local i, local v; pairs(arr))
   writefln("arr[", i, "] = ", v);

arr ~= ["foo", "far"];

writefln();

foreach(local i, local v; pairs(arr))
   writefln("arr[", i, "] = ", v);

writefln();

local function vargs(vararg)
{
   local args = [vararg];

   writefln("num varargs: ", #args);

   for(local i = 0; i < #args; ++i)
      writefln("args[", i, "] = ", args[i]);
}

vargs();

writefln();

vargs(2, 3, 5, "foo", "bar");


Produces:

Code:
hi 4, 5

foo: 5, 4.5

outer x: 3
inner x: 4
outer x: 4
inner x: 5

arr[0] = 3
arr[1] = 5
arr[2] = 7

arr[0] = 3
arr[1] = 5
arr[2] = 7
arr[3] = foo
arr[4] = far

num varargs: 0

num varargs: 5
args[0] = 2
args[1] = 3
args[2] = 5
args[3] = foo
args[4] = bar


Fantastic.

The current to-do list:

  • The compiler issues mentioned earlier.
  • The exception handling mechanisms and opcodes. I've got a good idea of what I'm going to do.
  • The API needs to be very much fleshed out in order to allow for the development of libraries.
  • The standard library.


This is going so much faster than I anticipated Smile

Edit - Other things I did. I updated the description of Foreach statements in the language spec; the original description was wrong. I also merged the vm module into the MDState class since having a separate VM module doesn't really offer any advantages, and the interpreter is mostly concerned with modifying the internal state of MDState anyway. Also fixed some fiddly type stuff, and made a minor fix to the language grammar regarding function parameters.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> MiniD All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group