Monster 0.8 + Tutorial

janderson askme at me.com
Fri May 9 22:32:45 PDT 2008


Nicolay Korslund wrote:
> janderson Wrote:
>> Hi,
>>
>> Nice work.
>>
>> So one thing I don't understand.  How would I bind a script into DMD or 
>> C++.  Also would this work with Visual C++?
> 
> You link the VM (which is a library) into your app, and call a function telling it to load the script file. At the moment the scripts have to be separate .m files in the file system, but more input options will come later (since that is a trivial thing to add.) You can then call script functions from your code (and vice versa using 'native' functions.)
> 
> I plan on writing tutorials on all this in the coming weeks, but for now the only "documentation" is the example set in the download.
> 
> The C++ API hasn't been set up for Windows yet, but it will basically be just a static library and a header file so it should work fine with VC++ when it's completed. 
> 
>> It would be nice if the D binding API supported features like automatic 
>> reloading (optional of course).  Knowing how to debug it in a debugger 
>> would also be useful (if possible).  Built in profiling would be another 
>> nice feature.
> 
> I'm not quite sure what you mean by automatic reloading, could you explain?

On most of the projects I've used game scripting languages on, design 
would simply run a bat file and instantly the running application/game 
would update with their new script.  A message would be displayed in the 
running app, "script blar.m reloaded.".

To save you some time if you plan to do this, here are some pointers:
1) Don't try date scanning lots files, this is fast for a couple of 
files but will thrash the disk for lots of files, leading to noticeable 
delays in the app.  Instead I recommend writing to an index file with 
the files that have changed.  Then monitoring that file for changes; Or 
using some other communication method.

2) A callback in the API to say when a script has changed would be 
useful.  The callback could either print a message or return false to 
prevent the script loading.


> 
> I agree completely about the debugger and profiler (and also coverage analysis and other statistics) and I plan on adding this at some point, but I don't know when.
> 
>> Does it use DMD as the underlining compiler?  How efficient is it?
> 
> If you mean the script compiler, then no. It's written entirely from scratch, and compiles to bytecode only.
> 
> As for efficiency, the overall design is build with efficiency in mind, but I have purposely done very little detail optimization. The internal architecture is going to change a lot, and optimizations would have to be maintained and redone all the time. Like they say, premature optimization is the root of all evil. But efficiency (speed and memory) will be THE top priority once the language becomes a little more mature.
> 
> - Nico

I totally agree about pre-mature optimisation.  I thought you might by 
compiling to a DLL or something.

Monster's pretty impressive stuff as its complicated stuff writing a 
programing language compiler.


More information about the Digitalmars-d-announce mailing list