eaker@sunbelt.crd.ge.com (Charles E Eaker) (03/12/91)
In casting about for "Forth-like" names for interpreted counterparts to IF, ELSE, and THEN, the candidates [IF] .IF and #IF (etc.) have been offered and commented on. Here's my two cents. I don't like .IF because it conflicts with the traditional use of the period to mean "print". I don't like [IF] because it puts the brackets in what will sometimes be the wrong place. In a definition one would have to use [ condition [IF] ] to do a run-time check to see what should be compiled, and the brackets around the IF strike me as redundant or misleading. Furthermore, brackets are not uniformly used in Forth to mark an immediate word (nor should they be). #IF is ok with me. When tens of thousands of programmers look at it for the first time, their gut reaction will be nearly correct. I don't mind porting C-isms to Forth as long as they aren't contrary to Forth custom. This usage of '#' doesn't conflict with its traditional one. A Forth-like set of names for conditional compilation would take advantage of a strong Forth association that is similar to the function of the proposed words. Since the proposed functions are basically those of skipping words in the input stream, we probably ought to pick something that uses parentheses, especially since we all know that ( is immediate. (Oops, maybe it should have been named [(] :-) ) The following works for me: : new-word [ condition ] IF( words-to-compile-or-interpret-if-condition-is-true )ELSE( words-to-compile-or-interpret-if-condition-is-false )THEN words-to-compile-or-interpret-no-matter-what ; A disadvantage (perhaps a serious one) is that C (and FORTRAN) programmers coming to Forth are likely to completely misinterpret IF( ... )THEN. But, I submit, this proposal is "Forthy". Chuck Eaker / P.O. Box 8, K-1 3C12 / Schenectady, NY 12301 USA eaker@crd.ge.com eaker@crdgw1.UUCP (518) 387-5964 -- Chuck Eaker / P.O. Box 8, K-1 3C12 / Schenectady, NY 12301 USA eaker@crd.ge.com eaker@crdgw1.UUCP (518) 387-5964