Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

DEC diagnostics would run on a dead whale. -- Mel Ferentz


devel / comp.lang.lisp / Formatting LISP Code

SubjectAuthor
* Formatting LISP CodeLawrence D'Oliveiro
+* Re: Formatting LISP CodeKaz Kylheku
|`- Re: Formatting LISP CodeLawrence D'Oliveiro
`- Re: Formatting LISP CodeJens Kallup

1
Formatting LISP Code

<umvosh$2d0do$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17704&group=comp.lang.lisp#17704

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.lang.lisp
Subject: Formatting LISP Code
Date: Tue, 2 Jan 2024 01:28:49 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 37
Message-ID: <umvosh$2d0do$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 2 Jan 2024 01:28:49 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="f7a0093f7e2d53773914881b75cc08dd";
logging-data="2523576"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+b94ciSpbVpKVHxmtu6zf4"
User-Agent: Pan/0.155 (Kherson; fc5a80b8)
Cancel-Lock: sha1:aMmK5Q1hsBE+G/pq1GaVVV2zBEA=
 by: Lawrence D'Oliv - Tue, 2 Jan 2024 01:28 UTC

I’m not a fan of the “parenthesis pileup” tradition of LISP code
layout. Having used a number of different programming languages over
the years, I have evolved a common set layout conventions that has
worked reasonably well across them. So for example, when parentheses
in LISP represent something resembling statement blocks, I like to put
the openers and closers at the same indentation level, which means
putting the closer on a line by itself. This, accompanied by a comment
indicating the type of construct being closed, I think helps a lot
with readability. Elisp example:

(defun convert-to-region-codes (beg end)
"converts alphabetic characters in the selection to “region indicator symbols”."
(interactive "*r")
(unless (use-region-p)
(ding)
(keyboard-quit)
) ; unless
(let
(
deactivate-mark
(intext (delete-and-extract-region beg end))
c
)
(dotimes (i (- end beg))
(setq c (elt intext i))
(cond
((and (>= c ?A) (<= c ?Z))
(setq c (+ (- c ?A) #x1F1E6))
)
((and (>= c ?a) (<= c ?z))
(setq c (+ (- c ?a) #x1F1E6))
)
) ; cond
(insert-char c)
) ; dotimes
) ; let
) ; convert-to-region-codes

Re: Formatting LISP Code

<20240101222400.379@kylheku.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17705&group=comp.lang.lisp#17705

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 433-929-6894@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.lisp
Subject: Re: Formatting LISP Code
Date: Tue, 2 Jan 2024 06:30:40 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 75
Message-ID: <20240101222400.379@kylheku.com>
References: <umvosh$2d0do$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 2 Jan 2024 06:30:40 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="9f1d5ef6f362c2671393529bacd0d31f";
logging-data="2705705"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19y8/feGUPV4yQqQmWmXwlMkPJ8rGrvCh4="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:9YUlCbM+j4sNpHJe2BpMS4zfmDQ=
 by: Kaz Kylheku - Tue, 2 Jan 2024 06:30 UTC

On 2024-01-02, Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
> I’m not a fan of the “parenthesis pileup” tradition of LISP code
> layout.

Well, you came to the right language. Odds are high that you will be
working alone in Lisp (not called LISP for a few decades now, by the
way).

So you will never run into a situation in which you're asked
to produce normal looking code ending in ))))) pringles.

(Unless you do something silly, like contribute a patch to someone
else's existing project.)

> Having used a number of different programming languages over
> the years, I have evolved a common set layout conventions that has
> worked reasonably well across them. So for example, when parentheses
> in LISP represent something resembling statement blocks, I like to put
> the openers and closers at the same indentation level, which means
> putting the closer on a line by itself. This, accompanied by a comment
> indicating the type of construct being closed, I think helps a lot
> with readability. Elisp example:
>
> (defun convert-to-region-codes (beg end)
> "converts alphabetic characters in the selection to “region indicator symbols”."
> (interactive "*r")
> (unless (use-region-p)
> (ding)
> (keyboard-quit)
> ) ; unless
> (let
> (
> deactivate-mark
> (intext (delete-and-extract-region beg end))
> c
> )
> (dotimes (i (- end beg))
> (setq c (elt intext i))
> (cond
> ((and (>= c ?A) (<= c ?Z))
> (setq c (+ (- c ?A) #x1F1E6))
> )
> ((and (>= c ?a) (<= c ?z))
> (setq c (+ (- c ?a) #x1F1E6))
> )
> ) ; cond
> (insert-char c)
> ) ; dotimes
> ) ; let
> ) ; convert-to-region-codes

You forgot a few, for instance:

((and (>= c
l?A) ;; >=
(<= c
?Z) ;; <=
) ;; and
(setq c
(+ (- c
?A
) ;; -
#x1F1E6
) ;; +
) ;; setq
) ;; cond pair

You go show `em how it oughtta be formatted!

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca
NOTE: If you use Google Groups, I don't see you, unless you're whitelisted.

Re: Formatting LISP Code

<un0bas$2imhq$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17706&group=comp.lang.lisp#17706

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.lang.lisp
Subject: Re: Formatting LISP Code
Date: Tue, 2 Jan 2024 06:43:40 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 12
Message-ID: <un0bas$2imhq$1@dont-email.me>
References: <umvosh$2d0do$1@dont-email.me> <20240101222400.379@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 2 Jan 2024 06:43:40 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="f7a0093f7e2d53773914881b75cc08dd";
logging-data="2710074"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19KIDzznqD9aZZitN8sKjPC"
User-Agent: Pan/0.155 (Kherson; fc5a80b8)
Cancel-Lock: sha1:9xc77a5uRmRqGwVnFDMERucK/B0=
 by: Lawrence D'Oliv - Tue, 2 Jan 2024 06:43 UTC

On Tue, 2 Jan 2024 06:30:40 -0000 (UTC), Kaz Kylheku wrote:

> On 2024-01-02, Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
>
>> So for example, when parentheses in LISP represent something
>> resembling statement blocks, I like to put the openers and closers at
>> the same indentation level, which means putting the closer on a line
>> by itself.
>
> You forgot a few, for instance:

Would you say those were “resembling statement blocks”?

Re: Formatting LISP Code

<kvhtupF62omU1@mid.individual.net>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17707&group=comp.lang.lisp#17707

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: paule32.jk@gmail.com (Jens Kallup)
Newsgroups: comp.lang.lisp
Subject: Re: Formatting LISP Code
Date: Tue, 2 Jan 2024 08:57:13 +0100
Organization: kallup non-profit
Lines: 56
Message-ID: <kvhtupF62omU1@mid.individual.net>
References: <umvosh$2d0do$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: quoted-printable
X-Trace: individual.net JPSYmgURVj3BDZr3qeT87wHFZiKxuedTEGXoCmVV6DbvEMpe7v
Cancel-Lock: sha1:zrzKCqXGt2o9julFBavJs94kVoU= sha256:JONUg21KRxKhBWSe/NJrBt7SXmHY40DnqPLH0J6QgYo=
User-Agent: Mozilla Thunderbird
Content-Language: en-US
In-Reply-To: <umvosh$2d0do$1@dont-email.me>
X-Antivirus: Avast (VPS 240101-4, 1.1.2024), Outbound message
X-Antivirus-Status: Clean
 by: Jens Kallup - Tue, 2 Jan 2024 07:57 UTC

Hi,

I using Common LISP, and I doing my Code-Formatting like You.
Because I came from different Language's, too.

From BASIC, to dBASE, to C/C++, to Pascal, to HTML...

In BASIC, I wrote very ugly Spagetty-Code in the first Time.
Then, something in the middle of all, I learn the Block-Scoped
Programming Style like:

BEGIN
BEGIN
...
END
END.

As I came to LISP, it was a Horror for me, and I don't could
understood, why the Programmers did use the old LISP-Style-Guide.

Some Times, I visit the LISP IRC Channels on freenode, I you can
thinking what happend...

Yes, they bann me :(

And since this, I learn more like before by doing-your-self with
Tutorials - but a coding Style, that is more modern, and suiteable
to all DSL, that I learn, and I think, I would learn.

This is not a good Sign, that old DSL die, and the existing Experts
goes into silent age.

And this is not, what me make the Language wrong. I use it very
often in my spare Time.

Many things you can do with it - but, you have to do many improvements
to hold the line with modern Applications.

Today, I think, it is not possible to "only" use one DSL for your
Projects !

So, I use SWI-Prolog, too.

My actual Project is a very strange, and Large Project - A more than
one Lifetime Project - to combine the advantages of all (okay: many)
under the hat of one Suite.

My ideas are so many, I have no Time for it :-)

Thanks for reading
Jens

--
Diese E-Mail wurde von Avast-Antivirussoftware auf Viren geprüft.
www.avast.com

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor