Nasal for C++ programmers: Difference between revisions

Jump to navigation Jump to search
m
Line 70: Line 70:


To learn more about the integration side of things, please see http://www.plausible.org/nasal/flightgear.html
To learn more about the integration side of things, please see http://www.plausible.org/nasal/flightgear.html
{{cquote|<nowiki>Nasal has always
been a fully functional language, with recursion, lexical closures and
anonymous lambda expressions. :)
This feature allows for calling Nasal scripts (not functions)
recursively.  That is, have a command binding that is a Nasal script,
that then calls another FGCommand object that is implemented in
Nasal.  Before, this wasn't possible because there was only one
execution context for the scripting engine.  Now you can have lots.
So you can, for example, stash one away on a timer while another one
runs.  This allows for pseudo-multithreading of many scripts at once,
which run forever in loops like:
  while(1) {
    if(NeedToUpdate()) { DoSomethingUseful(); }
    sleep(0.2);
  }
This kind of programming can be simpler than running from a timer.
Although the context is fairly heavy-weight compared with a timer
entry, so we don't want thousands of them sitting around.</nowiki><ref>{{cite web |url=http://www.mail-archive.com/flightgear-devel@flightgear.org/msg28436.html|title=<nowiki>Re: [Flightgear-devel] New nasal features coming</nowiki>|author=<nowiki>Andy Ross</nowiki>|date=<nowiki>Tue, 07 Dec 2004 10:36:23 -0800</nowiki>}}</ref>|<nowiki>Andy Ross</nowiki>}}
<references/>


Nasal itself has a standard library of general purpose functions, in addition it supports dozens of FG-specific extension functions to do various FG-related things, for example to interact with other subsystems (e.g. AI traffic, weather, FDM, GUI etc). In other words, while you'll find lots of standard library functions, there are many FG/simulation-specific functions available in FlightGear/Nasal.
Nasal itself has a standard library of general purpose functions, in addition it supports dozens of FG-specific extension functions to do various FG-related things, for example to interact with other subsystems (e.g. AI traffic, weather, FDM, GUI etc). In other words, while you'll find lots of standard library functions, there are many FG/simulation-specific functions available in FlightGear/Nasal.

Navigation menu