Conditionally compiled code (assert / check)

In other languages there’s the concept of asserts / checks, that get compiled out conditionally, usually on Release or Ship builds. It avoids adding instructions that check for conditions that are not dynamic. Basically testing for things that designers and/or artists are entering incorrectly. Is there something like that in Sk?

assert(tableEntry1 > 0.00001)
!myFormula : input1 / tableEntry1
assert(@actor ~= null)

In Sk there is Debug.assert() and Debug.assert_no_leak() (the latter also checks that no object references are leaked). These currently do not get compiled out in release builds though.

So if i put of a lot of asserts everywhere is there a recourse to manually commenting them out when it’s time to ship?

At the moment, no.

It is fairly easy to search through all .sk files for Debug.assert and replace with \\Debug.assert.

We plan to have a separate compilation for shipping builds that will remove them completely. There will be other build specific code block primitives as well. This would require separately compiled script binaries for different build types.

We could have shipping builds auto strip all Debug related commands. That would be fairly easy to implement and it would not require separate script binaries for shipping builds. That would also allow a simple toggle in shipping builds to not strip out Debug commands when you want a shipping build though you really want to run some Debug commands too. Such a toggle could even be per routine, per class or per class branch (class and all subclasses).

Any support on that front would help. Sounds like you’ve already thought some of it through which is great. On our end, building scripts that strip out code would not be preferable, although it’s ultimately not that difficult.

Pretty much everything that is in SkookumScript came about by prioritized need. Like much video game tech, if it wasn’t needed or on fire then it wasn’t built.

This means that there are still some planned fringe features that everyone would agree that they would be good to have though still possible to work around. It also means that there isn’t much fluff - everything has a purpose and was desperately needed at some point.

We are firm believers that “eating our own dog food” is the best way to make great tech and SkookumScript evolved in the AAA game industry on actual games.

We still have lots of mad stuff planned of course. :madsci:

We’ve just added that feature mentioned above that strips out Debug calls on load in shipping builds. It will be available in P4 soon.

1 Like

This code change is available in P4 now btw! Soon on GitHub too.