Sign in to follow this  
Rickmeister

Nasal, anyone

Recommended Posts

Rickmeister    182
Hehe.. Bad name for a script language anyway.. If you don't have a clue what I'm talking about Click here! Anyone who has tried it?? If so, I've got a question since the documentation is pretty close to non-existant.. It's extremely easy to extend and embed, but I've skimmed through the sourcecode and read all the comments in it and I still haven't found out if it's possible to call separate functions in a scriptfile.. This might be related to lack of sleep for the moment, and the fact that I'm beginning to feal really, really frustrated.. Besides this setback it's perfect for my project as I'm searching for something that doesn't rely on dll;s (can't use them due to certain issues) or bloats my exe when linked to statically. Nasal adds about 35k to my exe, and I can live with that. I've mailed to the author about this, but it's been a few days and he hasn't answered yet, and I've tried google but searching for 'Nasal' there gives a few interesting hits..

Share this post


Link to post
Share on other sites
Ranger_One    300
Well I've not seen it before now, but it's style is nice and pretty and the design doc is clear and forthright. I'm going to play with it more. I'll let you know if I figure anything out.

One this bugs me though, about the lexical closures. I must not understand them all that well since the example seems to be in error...

Share this post


Link to post
Share on other sites
Rickmeister    182
Quote:
Original post by Ranger_One
"I still haven't found out if it's possible to call separate functions in a scriptfile"

Do you mean: Call script functions from the host application?


Eehh.. Yeah.. Maybe.. English is not my 1st language, so I might have got it all wrong.. but I guess so..

Share this post


Link to post
Share on other sites
Rickmeister    182
Better clarify myself here..

If I've got a scriptfile like this (some sort of pseudo-nasal..[smile]):

testFunc = func {

x = arg[0];
for(x; x < 10; x++) {

doSomethingInCCode(x);
}
}


The doSomethingInCCode is a native C function declared like this:


static naRef doSomethingInCCode(naContext c, naRef me, naRef args);
/* and registered with the nasal (hehe.. still think it's funny) VM */

naHash_set(namespace, NASTR("doSomeThinsInCCode"),
naNewFunc(ctx, naNewCCode(ctx, doSomeThingInCCode)));


Is it possible to call the "testFunc" function in the script? I hope to get an answer from Andy Ross later.

Share this post


Link to post
Share on other sites
Rickmeister    182
Quote:
Andy Ross tells me:
The final argument to naCall is a hash containing the local namespace. So you can get the value of any symbols you set in there using a naHash_get() call on it.

Beware, though, that holding onto naRef structures in the outer
program can be dangerous -- you need to make sure that they are always
"findable" by the garbage collector, or else they will be cleaned up
from underneath you. There is a primitive naSave() API to do this,
but the best way is to make sure that they are always referenced from
another findable Nasal object.




Works like a charm now :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this