Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sdd.hp.com!spool.mu.edu!news.cs.indiana.edu!purdue!bouma From: bouma@cs.purdue.EDU (William J. Bouma) Newsgroups: comp.lang.forth Subject: Re: One and One doesn't equal two It equals 1 - The Who Message-ID: <14079@medusa.cs.purdue.edu> Date: 27 Mar 91 20:38:29 GMT Article-I.D.: medusa.14079 References: <9103271403.AA16095@ucbvax.Berkeley.EDU> Sender: news@cs.purdue.EDU Organization: Department of Computer Science, Purdue University Lines: 38 In article <9103271403.AA16095@ucbvax.Berkeley.EDU> "Frank C. Earl" writes: >On Mon, 25 Mar 91 10:43:42 GMT said: >> >>Sorry, but any Scheme or Lisp I know of will complain that '1' is not a symbol > >Indeed... But, Forth will let you do it... (I just LOOOVE that! ;) The Forth philosophy seems to be that everything read in is a WORD. Upon reading "1" and not finding an entry in the dictionary, the 'default` action of "1" is performed. Namely, to push the value 1 on the stack. This is consistent with Forth's refusal to acknowledge there are varied types of data. The interpreter refuses to read anything other than WORDs. Lisp simply has a different philosophy. Lisp is typed. The reader returns the value 1 when it sees "1", rather than the symbol who's name is "1". The reader returns a vector when it sees #() and a list when it sees '(). To have the reader return the symbol who's name is "1", the syntax (oh, no, that swear word again) is |1|. In lisp, (I am really talking only CL here, don't know how Scheme does it), I could thus say (defun |1| () 2) or (setq |1| 2) without error. Notice Forth would need a special syntax to distinguish numbers and names of numbers if its search order were changed. ie. Check if the string is a number first, if not, search in the dictionary. I have accidentally redefined a constant in FORTRAN before. One did (do? depends on the implementation I guess) this by calling a subroutine with a constant argument. Since FORTRAN passes arguments by address... This is a tough bug to find! However, I find it hard to believe anyone could accidentally do this in Forth. If you did misstype the name to a colon definition, it would be an easy bug to spot. You can love or hate that Forth allows you to do this. It is novel but potentially dangerous. What I dislike is the philosophy of Forth that makes it possible to allow you to do it. 8^) But you know that already. -- Bill