On Sun, Apr 29, 2007 at 12:46:12PM -0700, S'orlok Reaves wrote:
> 
> --- Mike Caron <[EMAIL PROTECTED]> wrote:
> > Well, the rule of thumb is: "If there's a way,
> > someone has done it"
> > 
> > I can't think of any particular reason why you would
> > want it to *not*
> > short circuit, but then, I'm not everyone in the
> > universe.
> 
> 
> The only one I can think of is side-effects. Something
> like:
> if (updateNPCs() || updateHero())
>    show message "An NPC or hero has hit a wall"
> end if
> 
> ...where updateNPCs() moves each NPC left a step and
> returns true if the NPC hits a wall, and updateHero()
> moves the hero right a step and returns true if the
> hero hits a wall.
> 
> I agree with you that if the feature exists, someone
> will want it. However, if ONLY short-circuiting is
> allowed, there are some easy workarounds.
> 
> You can pull the code out of the if statement:
> b1 = updateNPCs()
> b2 = updateHero()
> if (b1 || b2) 
>    show message "An NPC or hero has hit a wall"
> end if

The old bitwise and/or will never be short-circuit, so you can also 
write non-short-circuiting conditionals like this:

  if (updateNPCs(), or, updateHero())

or if you are worried about bitwise side-effects

  if (updateNPCs() <> false, or, updateHero() <> false)

---
Bob the Hamster
_______________________________________________
ohrrpgce mailing list
ohrrpgce@lists.motherhamster.org
http://lists.motherhamster.org/listinfo.cgi/ohrrpgce-motherhamster.org

Reply via email to