On 4/30/07, Mike Caron <[EMAIL PROTECTED]> wrote:
> On 4/29/07, S'orlok Reaves <[EMAIL PROTECTED]> 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
> >
> > If booleans can be coerced into integers, then you can
> > string them together with |:
> > if ((updateNPCs() | updateHero) != 0)
> >    show message "An NPC or hero has hit a wall"
> > end if
> >
> > Replace || with && (and | with &) to get a similar
> > non-short-circuited version of "and".
> >
> > This is ultimately a high-level decision for those
> > more familiar with using the CE to make. My take is
> > that short-circuiting everything is FAR less risky
> > then allowing both, and that those who want to force
> > evaluation of all parameters can easily make their own workaround.
> >
>
> I'm not concerned with new scripts, writen with the short circuiting
> in mind. But, if that script you mentioned was written in an old game,
> then suddenly it doesn't work any more.
>
> Then again, || and && didn't even exist until I added them a while
> ago, so... maybe it's not a big deal.
>
> --
> Mike Caron
> Final Fantasy Q
> http://finalfantasyq.com

We already have non shortcut evaluating versions. They're "and" and
"or", and even though they're bitwise, everyone already uses them. The
only problem is convincing people to use || and && instead of
complaining about bugs because they don't understand the bitwise
nature of "and" and "or". BTW, Hamsterspeak doesn't have a boolean
datatype.
TMC
_______________________________________________
ohrrpgce mailing list
ohrrpgce@lists.motherhamster.org
http://lists.motherhamster.org/listinfo.cgi/ohrrpgce-motherhamster.org

Reply via email to