From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Doug Hoffman Newsgroups: gmane.emacs.help Subject: Re: How to improve the readability of (any) LISP or any highlevel functional language to the level of FORTH ? Date: Fri, 07 Jan 2011 07:04:17 -0500 Organization: SunSITE.dk - Supporting Open source Message-ID: <4d270142$0$23753$14726298@news.sunsite.dk> References: <80ceeca0-1d32-47d1-ba96-feb4d9729c3a@v17g2000yqv.googlegroups.com> <767329f7-d300-4090-93cb-717d70fbadc4@i17g2000vbq.googlegroups.com> <87ei8rdo38.fsf@kuiper.lan.informatimago.com> <4d25c5f5$0$23761$14726298@news.sunsite.dk> <87bp3tdejx.fsf@kuiper.lan.informatimago.com> Reply-To: glidedog@gmail.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1294404044 11657 80.91.229.12 (7 Jan 2011 12:40:44 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 7 Jan 2011 12:40:44 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Jan 07 13:40:39 2011 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PbBcV-0004pD-7y for geh-help-gnu-emacs@m.gmane.org; Fri, 07 Jan 2011 13:40:39 +0100 Original-Received: from localhost ([127.0.0.1]:52630 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PbBcU-0000D9-7l for geh-help-gnu-emacs@m.gmane.org; Fri, 07 Jan 2011 07:40:38 -0500 Original-Path: usenet.stanford.edu!news.glorb.com!news2.glorb.com!news.glorb.com!dotsrc.org!filter.dotsrc.org!news.dotsrc.org!not-for-mail User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10.5; en-US; rv:1.9.2.8) Gecko/20100802 Lightning/1.0b2 Thunderbird/3.1.2 Original-Newsgroups: comp.lang.functional, comp.lang.lisp, gnu.emacs.help, comp.lang.forth, comp.lang.prolog In-Reply-To: <87bp3tdejx.fsf@kuiper.lan.informatimago.com> Original-Lines: 49 Original-NNTP-Posting-Host: 184.226.178.231 Original-X-Trace: news.sunsite.dk DXC=e3fOVEkFb=lbJlfT[; @_ShYSB=nbEKnkk=Wf0P_7c\Zf:je List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:78289 Archived-At: On 1/6/11 2:20 PM, Pascal J. Bourguignon wrote: > Doug Hoffman writes: > >> 2) The following is one way (of many) to approach this in standard Forth: >> >> : quad f{ a b c -- root } >> b FNEGATE b FDUP F* 4e a c F* F* F- FSQRT F+ 2e a F* F/ >> ; >> >> -2e 7e 15e quad f. >> -1.500000 >> >> Is it readable? Unless you're a Forther I would say no. But notice >> the complete lack of parentheses and operator precedences to resolve. >> Any competent Forther could quickly see exactly what is going on. > > Now, as a Forth programmer, ask yourself what you would have to do, to > call an operator with a variable arity? One way to handle a variable number of input parameters is to precede them with a count. There is at least one ANS Forth word that does this. I've seen the technique used a lot elsewhere in Forth code. Supplying a "mark" is also something I've seen. If I am going to apply a single operator to a list of many items, in Forth I would likely put the items in a list, perhaps a list of objects depending on the nature of the items, and then iterate over the list. Just to be clear, so we don't get sidetracked on a Lisp vs Forth tangent: I commented that I believed the Lisp example is somewhat readable to someone unfamiliar with Lisp, Forth is not readable to someone unfamiliar with Forth. The standard "Fortran/spreadsheet" syntax version is the most readable for this example regardless of language familiarity, again in my opinion. [snip] > (F/ (F* a 2e) > (F+ (FSQRT (F- (F* c a 4e) > (F* (FDUP (- b))))))) > > so it becomes readable again and you can see there's a bug in the Forth > expression. No, I can't see any bug in the Forth example. Could you point it out more clearly? -Doug