Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!uwm.edu!linac!att!ucbvax!MITCH.ENG.SUN.COM!wmb From: wmb@MITCH.ENG.SUN.COM (Mitch Bradley) Newsgroups: comp.lang.forth Subject: Re: Merits of Forth Message-ID: <9103221558.AA04938@ucbvax.Berkeley.EDU> Date: 21 Mar 91 20:49:54 GMT Sender: daemon@ucbvax.BERKELEY.EDU Reply-To: Mitch Bradley Organization: The Internet Lines: 43 > With all this discussion of the merits of Forth, I wonder if somebody could > comment on the usefulness of a language that merrily accepts things like: > > : 1 2 ; > > resulting in: > > 1 1 + . 4 ok In C, you can redefine library routines to do crazy things, e.g.: double exp(x) double x; { return (x-1); } but nobody does that because it is stupid. The linker will happily use your exp() routine in place of the one in the library. You can also do a fair amount of redefining in C using the preprocessor. The ability to substitute custom versions of "standard" routines is a valuable tool, if used with care. The difference between Forth and other languages in this respect is not qualitative, but rather one of degree. The dividing line between what is under the programmer's control and what is not is simply in a different place. In Forth, this dividing line is very close to one end of the spectrum; the programmer can change nearly everything if he wishes. In C, the dividing line in C is somewhat arbitrary: you can redefine things that are invoked with function call syntax, and you cannot easily redefine things that are invoked with infix syntax. The choice of whether to use infix or subroutine syntax for particular operators is pretty much up to the whim of the language designer. For instance, C uses infix syntax for the logical OR operator (i|j), but FORTRAN uses subroutine syntax (IOR(I,J)). Basic has in infix exponentiation operator, but C uses a subroutine. Most languages with simple syntax (Forth, LISP, PostScript) allow you to change most things. That is because those languages use the same syntax for user-supplied extensions and for built-in functions. Languages in the FORTRAN/Algol mold have a firewall between "first-class citizens" (infix functions) and "second-class citizens" (subroutines). Mitch