BrailNull propagation

time to read 1 min | 200 words

Here is a small, but interesting tidbit. Yesterday I have finally sat down and documented a lot of the changes that I made in Brail recently, I was surprised to see how much I had to document:

  • Auto Imports
  • Strongly typed variables
  • Sections
  • The "?variableName" syntax
  • Symbols
  • Null Propagation

The last part is what I want talk about now. Brail is a .Net language, which means that something like this:

output user.Parent.Name

will raise NullReferenceException if the user's parent is null. That can be somewhat of a pain in many scenarios. Brail now has a better syntax for this:

output ?user.Parent.Name

 will ignore any null values that it encounter in the way. It is will either output the parent's name or nothing at all.

The small print:

This will work only for variables that you get from the controller via the PropertyBag or Flash. You can't use it on variables that you define in the view. However, that is rare enough that I don't think that it is going to be a problem.

Note that I didn't document the DSL support in Brail yet, that is going to wait until it is stabilized a bit.

More posts in "Brail" series:

  1. (14 Jul 2007) Null propagation
  2. (30 Jun 2007) DSL Support Information
  3. (06 Apr 2007) Complex Expressions