Deutsch   English   Français   Italiano  
<20240402084057.881@kylheku.com>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Kaz Kylheku <643-408-1753@kylheku.com>
Newsgroups: comp.unix.shell,comp.unix.programmer,comp.lang.misc
Subject: Re: Command Languages Versus Programming Languages
Date: Tue, 2 Apr 2024 16:18:24 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 68
Message-ID: <20240402084057.881@kylheku.com>
References: <uu54la$3su5b$6@dont-email.me> <uu636l$7haj$1@dont-email.me>
 <20240329084454.0000090f@gmail.com> <uu6om5$cmv8$1@dont-email.me>
 <20240329101248.556@kylheku.com> <uu6t9h$dq4d$1@dont-email.me>
 <20240329104716.777@kylheku.com> <uu8p02$uebm$1@dont-email.me>
 <20240330112105.553@kylheku.com> <uudrfg$2cskm$1@dont-email.me>
 <87r0fp8lab.fsf@tudado.org> <uuehdj$2hshe$1@dont-email.me>
 <87wmpg7gpg.fsf@tudado.org> <LISP-20240402085115@ram.dialup.fu-berlin.de>
Injection-Date: Tue, 02 Apr 2024 16:18:24 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="d32078294708f72fe3a949b9ce8e6715";
	logging-data="3482803"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1+hETHh4rHc1tlKaUoBWeo5QgXszRZPCb4="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:F/KJfk3X+YZhTsipJsATXZZnoVA=
Bytes: 3436

On 2024-04-02, Stefan Ram <ram@zedat.fu-berlin.de> wrote:
> Johanne Fairchild <jfairchild@tudado.org> wrote or quoted:
>>You don't seem to much of a Lisp writer.  Lisp writers have no problem
>>reading that indentation.
>
>   Well, there is the expression "write-only code", which shows
>   that a good Lisp writer may not necessarily be a good reader.
>
>   This is an example of LISP code:
>
> ( SETQ DIFF
>   ( LAMBDA( X )
>     ( COND
>       ( ( ATOMP X )
>         ( COND
>           ( ( = X 'X )
>             1 )
>           ( T
>             0 )))
>       ( T
>         ( COND
>           ( ( =( CAR X )'SUM )
>             ( LIST 'SUM( DIFF( CADR X ))( DIFF( CADDR X )))))))))
>
>   . For someone who has not learned LISP, this is difficult to read,
>   /not/ because of the indentation, but because the words used have no
>   meaning for him. Without the indentation it would be harder to read.

I know all the words. It's still hard to read because of the weird
spaces.

This is the way of writing the code that the vast majority of the Lisp
word since gravitated toward:

  (SETQ DIFF
    (LAMBDA (X)
      (COND
        ((ATOMP X)
          (COND
            ((= X 'X) 1)  ;; unnecessary line breaks shored up here
            (T 0)))
        (T
          (COND
            ((= (CAR X) 'SUM)
              (LIST 'SUM (DIFF (CADR X)) (DIFF (CADDR X)))))))))

The code is from just before MacCarthy invented the ternary IF, as a
shorthand for a one clause cond:

  (SETQ DIFF
    (LAMBDA (X)
      (IF (ATOM X)
        (IF (= X 'X) 1 0)
        (IF (= (CAR X) 'SUM)
          (LIST 'SUM (DIFF (CADR X)) (DIFF (CADDR X)))))))

Also, modern cond clauses are not strictly pairs,
which allows the T to be omitted:

  (cond (this that) (else))  ;; rather than (t else)

when a cond clause consists of a single expression, then if that
expression is true, cond stops and yields that expression's value.

-- 
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca