I'd stop as soon as possible, IIf you'd let me

by Michael S. Kaplan, published on 2007/05/25 12:28 -04:00, original URI: http://blogs.msdn.com/b/michkap/archive/2007/05/25/2875426.aspx


I read Paul Vick's post IIF becomes If, and a true ternary operator and saw that a version of Visual Basic was finally going to have an IIF() that was going to properly short-circuit and not run both conditions.

And I thought about how they cheated on this in Access.

Well, technically not in Access, but in Jet. Or more specifically in the Jet Expression Service.

That is the component that does all the work to run code in queries, and also to handle all of the various possible expressions one could put into controls on forms and reports.

You ended up with that interesting (but subtle) difference in behavior where IIF() in a VBA function (that could be called from a query) could do something different than the identical IIF() code run from the query itself.

Since the first time I had ever known people to request IIF() to be a ternary operator was in Access 2.0/EB, I guess that this was accomplished in fewer than fifteen years....

And yes, it IS immediate if and not inline if. Wikipedia was wrong. Although I know lots of Access app developers who had the same misperception since they used it so commonly inside of properties to avoid writing separate VBA functions; this made it look like an "inline" operation so they called it that.

Never mind all the names people had for the debug window. :-)

 

This post brought to you by(U+2217, a.k.a. ASTERISK OPERATOR)


# orcmid on 25 May 2007 3:01 PM:

Wow, Paul Vick's explanation is interesting but why oh why "immediate" is thought to be informative escapes me.  

It is easier for me to grok IIF(c, t, f) as a function that selects one of its operands versus there being a conditional form where evaluation is guided dynamically by the evaluation of c (as in c ? t : f or the ALGOL expression form "if c then t else f" [which nested properly inside of if statements too]).  But the "immediate" is weird private language.

I guess it depends on what toolcraft you grow up with and what becomes tacitly understood.  The term is really not helpful, it seems to me.

Do you have more on the history of that?

# Michael S. Kaplan on 29 May 2007 11:46 AM:

Well, at least in Access (where there is an ES to do work), you either wrote a function to do conditional work, or you had an expression with an  IIf() -- which is a bit more immediate than writing a separate function.

Though that also makes it a bit more "inline" so really either word would have done....


Please consider a donation to keep this archive running, maintained and free of advertising.
Donate €20 or more to receive an offline copy of the whole archive including all images.

go to newer or older post, or back to index or month or day