Looking for a Lua alternative

Hipreme msnmancini at hotmail.com
Fri Dec 15 13:34:00 UTC 2023


On Friday, 15 December 2023 at 10:53:44 UTC, Bastiaan Veelo wrote:
> On Thursday, 14 December 2023 at 18:26:40 UTC, Siarhei 
> Siamashka wrote:
>> On Thursday, 14 December 2023 at 18:18:21 UTC, matheus wrote:
>>> Allocate();
>>> GC.disable();
>>> run_the_game();
>>> GC.enable();
>>
>> Is the `run_the_game()` part of code supposed to be annotated 
>> with the `@nogc` attribute?
>
> It depends, I guess. If it is not `@nogc` annotated, it can 
> still allocate and if it does it can run out of memory, unless 
> it calls `GC.collect` at the right moments. If it is `@nogc` 
> annotated, it cannot allocate and then the whole `GC.disable` 
> and `GC.enable` become unnecessary.
>
> -- Bastiaan.


First thing, if a game won't run out of memory this fast. You 
typically have many scenarios where it is desirable the GC to 
run. On level loading, when a level finishes, even at checkpoints 
are the main places which you can make the GC run, if you run out 
of memory doing that, it means your game ought to be slow no 
matter the language you're using since there is a lot of 
strategies to make it more efficiente (Pool objects).

Regarding the soft nogc, this is achievable by doing that one:

```d

     void main()
     {
         void main()
         {
             () scope @nogc
             {
                 writeln("Hello World");
             }();
             writeln("Hello World");
         }
     }
     ```


More information about the Digitalmars-d mailing list