MiniD 2 - Might as well be done

Jarrett Billingsley jarrett.billingsley at gmail.com
Sat Jun 20 11:10:22 PDT 2009


On Sat, Jun 20, 2009 at 6:27 AM, hasen<hasan.aljudy at gmail.com> wrote:
>
> Say, a guy like me, who's not very well experienced in writing useful
> applications (I mostly write throw-away code or university assignments).
>
> If I want to write a small program and I want to make it "scriptable", then
> I suppose that I can use MiniD for that, so do the docs explain how I can do
> that, or do you kinda assume that I already have an experience doing this
> kind of thing?

After I wrote the last post, I realized there are two possible
interpretations of your question.  Either you want to know in what
areas of your program it'd be possible to add scriptability - which I
already answered - or you were looking for a more practical answer.
Practically speaking, it's pretty simple.  Setting up objects in the
scripting language's namespaces is easy enough, and though it might
look a bit odd ("pushInt(t, 1); newGlobal(t, "numPlayers");"), it's
very simple and repetitive, meaning it can be abstracted and
automated.  Calling script code is equally simple: instead of doing a
normal function call, you just use a couple API functions to get the
function you want to call, call it, and get any return values (if
any).  Again, this can be abstracted out into higher-level mechanisms.
 minid.bind - horrible thing that it is[1] - tries to do some of that
for you, automatically wrapping functions, classes, and structs the
best it can so that D and MiniD code can interact with each other
almost seamlessly.  There are other options, like team0xf's xpose,
which now has support for MiniD as far as I remember.

If you'd like the docs to have some examples on common native-script
interaction tasks.. well, yeah, they probably should anyway ;)

[1]I say "horrible thing that it is" because it's a tedious mess of
horrible string mixins, templates, .stringof parsing hacks, and the
like.  It is an expression of everything that is wrong or inadequate
with D1's (and D's, in general) metaprogramming abilities.  Using it
also has the potential to kill OPTLINK, since it causes lots of
template instantiations in one spot.  I can only imagine how much
simpler - and as a consequence, more robust - the library would be
even if I had nothing more than __ident.


More information about the Digitalmars-d-announce mailing list