Posts Tagged null

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 52 – Idioms and Best Practices

Tags: , , , , , , , ,

As a very large language used for a very wide range of purposes over many decades, C++ can be written in a lot of different ways. Today we’ll look at some of the norms for “modern” C++ to get a sense of how code is normally written.

Read the rest of this article »

6 Comments

NotNull and Owner

Tags: ,

The Guidelines Support Library is a small collection of utilities for C++. Today we’ll look at how two of them can make our C# code safer and cleaner.

Read the rest of this article »

7 Comments

Three IL2CPP Optimizations

Tags: , , ,

This week we’ll take a break from the C++ Scripting series to explore three optimizations we can make to our C# code so that IL2CPP generates faster C++ code for us. We’ll cover three areas that yield big speedups: casting, array bounds checking, and null checking.

Read the rest of this article »

3 Comments

C++ Scripting: Part 9 – Out and Ref Parameters

Tags: , , ,

It’s been quite a while in the series since we’ve added any fundamental C# language features. Today we’ll address one of the limitations of the C#/C++ communication: the lack of support for out and ref parameters. This is important as they’re commonly used by both the Unity API and .NET and we’d like C++ to be able to call functions with these kinds of parameters. So let’s delve into what it means for C++ to use out and ref parameters and see how to implement support for that across the language boundary.

Read the rest of this article »

2 Comments

Comparing Null Objects

Tags: , , ,

We all use <, <=, >, and >= with integers and floating point values all the time. It just works and it’s built into basically every programming language. These simple operators suddenly become quite a pain when you start wanting to compare other objects. IComparable seems to make it easier, but there’s some trickiness when you start dealing with null objects. Today’s article explores this and ends up with some handy utility functions to take some of the gotchas out of comparing.

Read the rest of this article »

No Comments