BrailNull propagation
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:
- (14 Jul 2007) Null propagation
- (30 Jun 2007) DSL Support Information
- (06 Apr 2007) Complex Expressions
Comments
?user.Parent.Name
Nice one! :-)
http://www.visual-design.se/blog/posts/200411251000.asp
/Mats
Finally you have time for this :) May I have a url? Its on your wiki?
Was this code comment documentation or something you put on the Castle Wiki? Just wanted to check it out and give it a read.
It is an update to Castle's Docs.
It should be here:
http://www.castleproject.org/monorail/documentation/trunk/viewengines/brail/index.html
But I don't see my changes, let me check that.
Changes are being held for now, at least until the RC3 is finally announced.
Comment preview