Posts Tagged assert

Searching for a Non-Nullable Reference Type

Tags: , , ,

The inventor of null references has called them his billion dollar mistake. We’ve all felt that pain so many times. After a while it can seem like null references are inevitable. They’re just a built-in sharp edge we have to carefully avoid cutting ourselves on. But is this true? Is there some way we can avoid the possibility of a null reference in the first place? Today we’ll go searching for such a mythical type.

Read the rest of this article »

8 Comments

C++ For C# Developers: Part 23 – Compile-Time Programming

Tags: , , , , , ,

The vast majority of the code we write executes at runtime. Today’s article is about the other kind of code, which runs during compilation. C# has very limited support for this. In C++, especially its newer versions, most of the language features are usable at compile-time. Read on to learn how to take advantage of this!

Read the rest of this article »

5 Comments

Optional<T>: A Nullable<T> Alternative

Tags: , , , , ,

Today we’ll make a new type that addresses some of the deficiencies in Nullable<T>. We’ll end up with a good tool for dealing with operations that may or may not produce a result or take a parameter, even in Burst-compiled code. Read on to see how it works!

Read the rest of this article »

2 Comments

The Virtue of Stopping

Tags: ,

What do you do when your code finds a bug? We write code to check for null references and out-of-bounds indexes all the time. What’s the proper way to respond when we find a problem? Today we’ll look at two options and see how they pan out.

Read the rest of this article »

10 Comments

Assertions in Burst

Tags: , , ,

Assertions are an incredibly handy tool, but do they work in Burst-compiled jobs? Today we’ll find out!

Read the rest of this article »

6 Comments

BitArray32 and BitArray64

Tags: , , , ,

C# already has two bit array types, but both are lacking. BitArray is a class so it requires heap allocation and GC. BitVector32 is a struct, but it’s usage is bizzare, it’s implemented inefficiently, it’s not enumerable, and there’s no 64-bit version. Today we’ll create a new, simple type to remedy these issues and add a new tool to our toolbox!

Read the rest of this article »

6 Comments

Handling Internal Errors

Tags: , , ,

Some errors can be handled and some cannot. Nevertheless, it’s extremely common to see codebases chock-full of ineffective error handling for these unrecoverable issues. The result is a lot of extra code to write, maintain, and test that often serves to make debugging harder. Today’s article shows you how to make debugging internal errors so much easier by effectively writing code to handle them.

Read the rest of this article »

2 Comments

How to Use Runtime Asserts to Find Bugs

Tags: , , , ,

Runtime asserts, not the asserts in unit tests, are a valuable debugging tool for any game developer. Today’s article shows you what they are, how to use them, how not to use them, and how they work. Read on to learn more!

Read the rest of this article »

No Comments

Creating A Better Assert Function

Tags: , , ,

The assert function is found in many languages to provide a way for you to check for errors only in debug builds of your code. For release/production builds, the asserts are removed to make the compiled code smaller and remove all of the overhead of the error checking. Flash doesn’t come with such a feature built-in, but can we build one ourselves? Today’s article will try to do just that using nothing but Adobe’s modern AS3 compiler: ASC 2.0.

Read the rest of this article »

3 Comments