help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to improve the readability of (any) LISP or any highlevel functi


From: Doug Hoffman
Subject: Re: How to improve the readability of (any) LISP or any highlevel functional language to the level of FORTH ?
Date: Wed, 19 Jan 2011 08:45:37 -0500
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

On 1/18/11 5:55 PM, m_l_g3 wrote:
On Jan 1, 10:04 am, girosenth<girose...@india.com>  wrote:
How to improve the readability of (any) LISP or any highlevel
functional language to the level of FORTH ?

...

How do you make it readable ?
...

(f (g (h (j (k (l ops)))...)))

(e
    (f
       (g (h i)
          (j k l)
       )
       (m (n o (p q))
          (r (s t) u)
)  )  )

The rule: if you don't see the closing paren moving the eyes down,
it's on the right.
But it either to the right or down, no other option.

I would assume that Lispers would use a source editor that automatically hilights corresponding parens (e.g., selct a left paren and the right paren becomes bold or whatever) and checks for missing parens automatically before compilation is attempted.


As to Forth, you may try to layout control structures on the right,
as if RPN is not enough:

: MAX   2dup>       if
             drop    else
             nip     then
;

I agree with vusual "aligning" for control words. But I would do it differently (stack comment please!). The above suggests to me that ELSE is consuming the result of the DROP and THEN is consuming the result of the NIP.

Better, IMHO:

: MAX ( n1 n2 -- max )
  2dup > IF   drop
         ELSE nip
         THEN ;

Read in English as " <condition> iftrue DROP, otherwise NIP, then continue".

-Doug


reply via email to

[Prev in Thread] Current Thread [Next in Thread]