v1.2.2 variable scoping and web export fix


MotC version 1.2.2 has been released.

Variable scopes

"for", "while", "if" and "else" statements now create variable scopes. Variables declared within a scope are deallocated when the program exits the scope, and variable names can be re-used in separate (non-overlapping) scopes.

Variables declared in "for" loop initialisers are also considered part of the "for" loop scope.

This is a breaking change! But I think it's worth it for the cleaner code. Fixing up old programs should be pretty straightforward.

Web export

Programs exported to web can now access files in sub-folders (so long as you have included them using the #file directive).

Previously the file would fail to open at runtime unless they were in the root folder.

Garbage collector improvements

Some under-the-hood changes have been made to the automatic garbage collector to help it better reclaim memory:

  • The memory reference format has been reworked to reduce collisions with small integers
  • A quicker non-compacting garbage collection is run after every 5000 allocations, so identify and re-use allocation table entries

Miscellaneous

  • `stat(MEMORY_FULLGCCOUNT)` can be used to return the count of full (compacting) garbage collections. `stat(MEMORY_GCCOUNT)` returns the count of all garbage collections (compacting or otherwise).
  • New elapsed time functions:
    • `timer()` returns the number of seconds since the program started.
    • `resettimer()` resets the timer to 0.
  • The sample programs have been tidied up a little. #file directives have been added to those that reference files, so that they can be exported as-is.

Files

motc-1.2.2.zip 4.6 MB
89 days ago

Get MotC

Download NowName your own price

Leave a comment

Log in with itch.io to leave a comment.