Re: if statement not working

new topic     » goto parent     » topic index » view thread      » older message » newer message

-------Phoenix-Boundary-07081998-

Hi Derek Parnell, you wrote on 3/22/02 5:48:27 PM:

>However, in my never-ending quest for readable code, the phrase "match(a,b)
>= 1" is not obviously telling the reader that I'm trying to see if 'a'
>begins with 'b'. That's part of the ambiguitity of using literal numbers in
>code; you don't know if they are special (magic) numbers or not. So I could
>make it a bit better by doing:
>
>   constant beginning = 1
>   . . .
>   if match("*AUTHOR ", s) = beginning then
>
>but that looks a bit ambiguous too. Or :
>
>   if begins(s, "*AUTHOR ") then
>
>but that sounds unusual if you say it out loud.
>
I think

    if begins_with (s, "*AUTHOR ") then

is self-explanatory.
Or how about another oddball operator (infix function??)

    if s <begins_with> "*AUTHOR " then

!?

Karl Bochert

-------Phoenix-Boundary-07081998---

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu