There is currently a big debate in the Groovy mailing list about

        <expression> if <condition>
        <expression> unless <condition>

Isn't the discussion on the relative ordering of <expression> and
<condition> related to subject/object/verb ordering in languages?
Figure 792.7 of gives some
figures for number of languages using various orderings.

What are the semantics here, the expression is evaluated if the
condition is true?  I would be confident that developers would want
to comprehend the condition first.  So if they read the code from
right to left it would make sense to put the condition on the right.
Unfortunately there is no data to reliably tell us how developers
read could at this level of granularity.

With regard to the unless form, there is some experimental work
showing that people first take a statement to be true and then
have to put additional cognitive effort into negating it.  So false
statements take longer to evaluate than true ones (sorry no reference
to hand).  This is one reason, perhaps a small one, not to use this
form.  What are the benefits of the 'unless' form?  I cannot
think of any.

arguments people are putting forward on readability and comprehension
are based simply on personal experience and prejudice.  What I would

Not all of them (which is usually the case)?  What experimental findings
did they cite?

Derek M. Jones                         tel: +44 (0) 1252 520 667
Knowledge Software Ltd                 mailto:[EMAIL PROTECTED]
Source code analysis         

Reply via email to