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

September 28th -- finally free

 
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: Thu Sep 28, 2006 8:29 pm    Post subject: September 28th -- finally free Reply with quote

WHELL after three weeks, I've finally got some free time to work on MiniD! Here's what's going on:

  • Haven't worked too much on classes. But one thing that has changed is that there is now no "new" expression for various reasons. Instead, like Squirrel, to instantiate a class, you call the class as if it were a function, and that will create an instance and call the "constructor" method.

  • Created the new "delegate" type and got it working. It's a little suboptimal performancewise, but that can certainly be changed. What has changed with it, however, is that it's still a native type but it has no special syntax. Instead, you call the "delegate" library function to create it. In addition, you can bind as many parameters to a function as you'd like -- think currying in functional languages.

    Code:
    local function foo(x, y, z)
    {
        writefln("x = ", x, " y = ", y, " z = ", z);
    }

    local dg1 = delegate(foo, 2);
    local dg2 = delegate(foo, 5, 6, 7);

    dg1(3, 4); // writes "x = 2 y = 3 z = 4"
    dg2(); // writes "x = 5 y = 6 z = 7"


    This, of course, can be used to create D-style delegates, that is, you can bind a "this" parameter to a class function:

    Code:
    class A
    {
        x = 0;

        method foo()
        {
            writefln("x = ", this.x);
        }
    }

    local a = A(); // notice the new syntax to instantiate a class
    a.x = 5;
    a:foo(); // prints "x = 5"

    local dg = delegate(A.foo, a);
    dg(); // prints "x = 5"


  • Been thinking about iteration, and I think I'm going to keep it Lua-style. I was thinking about making it D-style, where foreach bodies are turned into callback delegates, but that's just kind of a pain in the ass, and also involves creating a new closure for the foreach body every time the loop starts (the first time, not every iteration). So I'll keep it Lua-style. I also thought about making a new "iterator" or "generator" type, one which the VM would know would be collectable as soon as the loop is over, for performance, but that's kind of a minor issue.


So yeah. I've got some homework to do this weekend, but it's really basic C programming, so that shouldn't take long. So it looks like a weekend of fun!
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