Des (deskitty) wrote,
Des
deskitty

  • Mood:
  • Music:

Dryice Update

So ... I was quite productive yesterday with Dryice.

Libdiutil is mostly ready to go. I think there might be a few more bits of documentation that need to be done, but it's passing all its unit tests now, which makes me inordinately happy. I can now concentrate on writing the meat of the language ... I can decide things like "What is an object?" "What is a class?" "What basic operations will the language support?" and all that other fun stuff.

I'm still wrestling with two problems, though ... first is the constructor problem, and then the problem of how to handle parameterized types (a la C++'s class templates).

>>> More Constructor Problem Ideas

I think I have an idea about the constructor problem ... perhaps have a real "constructor" (like C++, Java, etc), but make it return the constructed frame which contains all the object's private data, e.g.:

class My3DPoint(int: x, int: y, int: z) is My2DPoint(x, y):
    {
        frame(
            // x and y are handled by the 2d point earlier
            int: _z = z
        )
    };

    public function<My3DPoint>: blah = { ... };
.


[A frame is an object that holds name->value pairings, but unlike a dictionary or hash, those pairings can't be changed once the frame is created. In Dryice, there is one frame per class in an object, to hold that object's private data.]

...except that seems very unwieldy, and it requires some special-casing with respect to parameters passed to the constructor (so that the parent class' constructor gets called first and with the right parameters).

Or perhaps I only allow has-a relationships internally and add some syntactic sugar to make some of those has-as look like is-as:

class My3DPoint:
    { let (int: x, int: y, int: z).
        object(
            class My3DPoint;
            is My2DPoint(x, y);
            int: _z = z;
        )
    }
.


...except that also presents a problem, because it opens up the possibility for dynamic inheritance which tends to make things slow (I don't want to look at each individual class in the inheritance tree to find a method), or memory-intensive (no, thank you, I don't want to maintain a list of public members for each and every single object :p). It also doesn't handle interfaces too well (yes, as in Java interfaces ... I don't like the idea, but it's easier to implement and more deterministic than multiple inheritance), and it still has the same kludgy feel as solution #1.

I'm not really sure which of the two is more palatable ... I think this is one of those things I'm going to have to sit and play with for a while before I come up with a decent answer.

-- Des
Subscribe

  • Memorial Weekend

    This was a surprisingly eventful memorial day weekend, for not having been planned in advance. Friday night, yelang,…

  • March goings-on, and getting physically healthy

    Seems like every time I have occasion to sit down in front of an LJ window, my mind blanks. Thus, no posts. I've mostly been amusing myself with…

  • (no subject)

    Andy: "I have everything I could ever want, and things that aren't my friends." I'm right there with ya, my friend. =) -- Des

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 15 comments

  • Memorial Weekend

    This was a surprisingly eventful memorial day weekend, for not having been planned in advance. Friday night, yelang,…

  • March goings-on, and getting physically healthy

    Seems like every time I have occasion to sit down in front of an LJ window, my mind blanks. Thus, no posts. I've mostly been amusing myself with…

  • (no subject)

    Andy: "I have everything I could ever want, and things that aren't my friends." I'm right there with ya, my friend. =) -- Des