Adam Caudill

Security Leader, Researcher, Developer, Writer, & Photographer

IIf() May Get a Dose of Legitimacy

Paul Vick announced a possible change for VB 9.0, this change would give the IIF method the legitimacy it has long deserved. The issue with IIf is that it’s not a short-circuit operator, which can severely limits its usefulness. Take the following example, that will throw an exception if obj is Nothing:

IIf(obj IsNot Nothing, obj.Property1, String.Empty)

Since IIf() is just a normal method, all parameters will be evaluated, regardless of weather obj is Nothing. This change would make IIf a true part of the language, a true ternary operator, instead of just another method.

IIf is largely avoided due to performance issues, and its limited usefulness for the reason above. Now that IIf may function as a true operator (though still wrapped in the cloak of a method), it will be a truly useful part of the language, one that I’ve long wished for. I’ve always been a fan of IIf, it’ll be nice to be able to use it again, without the overheard and issues that has long went with its use.

Mr. Vick is still soliciting comments on this change, so now is the time to make your opinion known.

Adam Caudill


Related Posts

  • Running RegEdit as SYSTEM

    While facing an interesting research challenge, digging into the inner working of Windows, I realized that I needed to change a registry value. That’s simple enough, I fire up RegEdit, make the change, then politely as RegEdit knows how, it told me that I couldn’t change the value! Being one that hates when my computer tells me I can’t do something, I had to find another option. So after some research, I found my answer: sc.

  • Superstars & Monkeys

    I really enjoy what I do, and though I work in a chaotic environment, I really do love my job. Being in the Software Development industry has some really nice perks, being a developer in today’s world really is a great thing. Development isn’t easy though, it is quite mentally demanding; clear focus is of paramount importance. Without absolute focus, progress will only be a dream. This fact is a key player as to what makes being in this industry so great.

  • Rosen Shingle Creek

    I recently had a great idea; a trip down to Florida to visit family and celebrate our second anniversary – the idea turned out to be a bit less great than I had hoped. Of the seven days we were there, on three the wind-chill was less than 40F. On the upside, I had booked a room at a newer (opened in 2006) 4-star hotel; if we’re going to be stuck inside, no reason not to be in a great room.

  • Task Management with Tasks

    After being reminded of Alex King’s excellent Tasks task management system by a Download Squad article, I decided it was high time to give it a try. I had seen the software before, but never really evaluated it to see if it would be of any real use to me. This time, I gave it a more thorough look. I’ve been doing a fair bit of reading in recent weeks about time and task management; and thus I’m trying to build a better process than what I use now.