1. Re: Short Circuiting
- Posted by Andy Kurnia <akur at DELOS.COM> Jun 25, 1998
- 500 views
>Date: Wed, 24 Jun 1998 15:10:25 -0400 >From: Robert B Pilkington <bpilkington at JUNO.COM> >Subject: Re: Short Circuiting > > if find("EOF", s) then > ... [alpha] > else > [gamma] > end if > >Although this would give the wrong results if s = "eeeEOF", as opposed to >s = "EOFjkl", but given the context, seems pretty appropriate to me. >Yeah, yeah, I know this is supposed to be an example of hard code that >short-circuiting would make easier.... But.... if match("EOF", s) = 1 then --> assuming s is sequence It works, but I'd rather see the not-using-a-function (compare is NOT seen as a function, after all it's a standard operator in most languages; match IS seen as a function, in BASIC you use INSTR, in Pascal you use Pos, in C you use strchr, in Perl you use index, i.e. no language has find as an operator) version. (Btw yes I know lots of languages.) Btw it's not find... >global function same(sequence s1, sequence s2) > return not compare(s1, s2) -- if equal return 1, otherwise return 0. >end function I'd rather use objects in the arguments