JarrettBillingsley
Joined: 20 Jun 2006 Posts: 457 Location: Pennsylvania!
|
Posted: Thu May 17, 2007 6:17 pm Post subject: |
|
|
That's kind of approaching how the API will be laid out, I think. See, it would be really nice to be able to do:
Code: |
MDValue a = 3;
MDValue b = 6;
MDValue c = a * b;
MDValue d = new MDArray(5);
d[0] = a;
d[1] = b;
d[2] = c;
|
But the problems with this are (1) what about metamethods? What if I were doing this on other types which had metamethods defined? and (2) what MDState should be used if there's an error, or to call metamethods if that gets ironed out?
One alternative is a Lua-like API, but that's pretty awful.
So I've been thinking of something like:
Code: | with(s) // s is an MDState
{
MDValue a = 3;
MDValue b = 6;
MDValue c = mul(a, b); // this is a method of s
MDValue d = new MDArray(5);
idxa(d, 0, a);
idxa(d, 1, b);
idxa(d, 2, c);
} |
It's starting to look a bit like the NekoVM FFI. This has the advantages of (1) being pretty clean, much cleaner and more straightforward than the Lua API certainly, (2) allowing for metamethods, and (3) having a state for calling metamethods and throwing errors. |
|