Agreed... It's Bad Style. I was merely pointing out the syntactic possibilities.<br><br>That being said, a bad programmer can screw up a program while using the best programming language... and a good programmer can make something that is usually Bad Style look better than the efforts of a bad programmer using Good Style :)<br>
<br><div class="gmail_quote">On Thu, May 15, 2008 at 11:15 PM, Richard A. O'Keefe <<a href="mailto:ok@cs.otago.ac.nz">ok@cs.otago.ac.nz</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d"><br>
On 16 May 2008, at 9:42 am, Edwin Fine wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I saw something like this in some Erlang code. It is possible to achieve a similar effect without using "if" as follows:<br>
<br>
is_list(X) andalso string:to_lower(X) == X andalso length(X) == 5 and also my:no_duplicates(X) andalso do_something(X).<br>
</blockquote>
<br></div>
I respectfully suggest that it is Bad Style to put something with a side<br>
effect in an 'andalso' or 'orelse'.  They are for evaluating conditions,<br>
and if you put side effects, you are guaranteed to confuse people who<br>
expect you to use them for that purpose.<br>
<br>
        case is_list(X) andalso<div class="Ih2E3d"><br>
             string:to_lower(X) == X andalso<br></div>
             length(X) == 5 andalso<br>
             my:no_duplicates(X)<br>
          of true  -> do_something(X)<br>
           ; false -> ok<br>
        end<br>
is longer, but far far clearer.<br><font color="#888888">
<br>
--<br>
"I don't want to discuss evidence." -- Richard Dawkins, in an<br>
interview with Rupert Sheldrake.  (Fortean times 232, p55.)<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
</font></blockquote></div><br>