Re: if statement not working

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

----- Original Message -----
From: <kbochert at ix.netcom.com>
To: "EUforum" <EUforum at topica.com>
Subject: Re: if statement not working



>I think
>
>    if begins_with (s, "*AUTHOR ") then
>
>is self-explanatory.

Maybe, but is this asking if s begins with "*AUTHOR ", or "*AUTHOR " begins
with s ? It is not so unambiguous really.

>Or how about another oddball operator (infix function??)
>
>    if s <begins_with> "*AUTHOR " then

I like the idea of infix functions. I notice in the D news-group this is
sometimes discussed. It must be a real pain for interpreter/compiler writers
to do well though.

PreFix functions are where the function name appears to the left of its
parameters, infix functions have parameters before and after the function
name, and postfix functions have their parameters on the lefthand side.

   Prefix:    add a b
   Infix:      a add b
   postfix:    a b add

Most languages support prefix functions, some post fix (eg Forth) , but
rarely infix. Infix is usually only reserved for operators such as + and *.

So how about something like :

 infix function begins_with( object x : object y )
   return (match(y,x) = 1)
 end function

 if a begins_with b then
    . . .
 end if

Just a thought  blink
-----------
Derek

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

Search



Quick Links

User menu

Not signed in.

Misc Menu