Nasal Loops: Difference between revisions

Jump to navigation Jump to search
1,213 bytes added ,  1 February 2014
no edit summary
(forum2wiki)
No edit summary
Line 40: Line 40:
We're hoping to look into this again this year - anybody interested in helping with this, should check out Philosopher's "Nasal internals" document in $FG_ROOT/Docs
We're hoping to look into this again this year - anybody interested in helping with this, should check out Philosopher's "Nasal internals" document in $FG_ROOT/Docs


Nasal loops are 'worse' than C++ loops since the former tend to trigger garbage collection more often, which leads in the worst case to an artificially prolonged frame. Some people claim to have had serious issues with Nasal GC.
it is entirely true that ANY Nasal code, including loops, may end up triggering the GC - even due to code unrelated to the loop itself, what we commonly referred to as "GC pressure", i.e. due to certain coding constructs being more likely to add to the "GC pressure".
C++ loops should normally not trigger the Nasal GC at all, unless the C++ code happens to call back into Nasal space.
Normally, there's a vector of subsystems that's iterated in the FG main loop, each subsystem's update() method is then called, including the update() method of the Nasal subsystem.
However, most Nasal code is not directly called via Nasal::update(), but instead via callbacks by other C++ subsystems, such as events (for timers) or the property tree code (for listeners), but also the AI traffic system, scenery system - or even the GUI system, whenever Nasal hooks are supported by the system, the corresponding system needs to reach back into Nasal space, which may end up triggering the GC.
== for, while, foreach, and forindex loops ==
== for, while, foreach, and forindex loops ==
Nasal's looping constructs are mostly C-like:
Nasal's looping constructs are mostly C-like:

Navigation menu