[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#58812] [bug#59164] Coding style: similarly-named variables
From: |
zimoun |
Subject: |
[bug#58812] [bug#59164] Coding style: similarly-named variables |
Date: |
Mon, 21 Nov 2022 16:02:19 +0100 |
Hi Maxim,
On Fri, 18 Nov 2022 at 12:02, Maxim Cournoyer <maxim.cournoyer@gmail.com> wrote:
> The intent was to keep away from the following imperative style, which
> hurts both readability and debuggability in my opinion:
>
> --8<---------------cut here---------------start------------->8---
> (let* ((my-target "something")
> (my-target (mutate-once my-target))
> (my-target (mutate-twice my-target)))
> (do-something-with my-target))
> --8<---------------cut here---------------end--------------->8---
Well, ’mutate-*’ is not really mutating. Maybe I miss something and
from my understanding, this ’let*’reads,
--8<---------------cut here---------------start------------->8---
(let ((my-target "something"))
(let ((my-target (mutate-once my-target)))
(let ((my-target (mutate-twice my-target)))
(do-something-with my-target))))
--8<---------------cut here---------------end--------------->8---
and not,
--8<---------------cut here---------------start------------->8---
(begin
(define my-target "something")
(set! my-target (mutate-once my-target))
(set! my-target (mutate-twice my-target))
(do-something-with my-target))
--8<---------------cut here---------------end--------------->8---
Well, the former is ’lexical-scope’d so the 3 ’my-target’ are not truly
an imperative style, I guess.
Back to the pattern, you are suggesting to write,
--8<---------------cut here---------------start------------->8---
(let* ((my-target "something")
(my-target* (mutate-once my-target))
(my-target** (mutate-twice my-target*)))
(do-something-with my-target**))
--8<---------------cut here---------------end--------------->8---
well, I am not convinced it helps for readibility. And I think, the
pattern is manually doing what ’let*’ is already doing for you.
Cheers,
simon
- [bug#58812] [PATCH v3 3/4] guix: shell: Add '--symlink' option., (continued)
- [bug#58812] [PATCH 0/5] Add --symlink option to 'guix shell'., zimoun, 2022/11/16
- [bug#58812] [PATCH 0/5] Add --symlink option to 'guix shell'., Ludovic Courtès, 2022/11/09
- [bug#58812] [PATCH 0/5] Add --symlink option to 'guix shell'., Maxim Cournoyer, 2022/11/09
- [bug#58812] [bug#59164] Coding style: similarly-named variables, zimoun, 2022/11/17
- [bug#58812] [bug#59164] Coding style: similarly-named variables, Maxim Cournoyer, 2022/11/18
- [bug#58812] [bug#59164] Coding style: similarly-named variables,
zimoun <=
- [bug#58812] [bug#59164] Coding style: similarly-named variables, zimoun, 2022/11/21
- [bug#59164] [bug#58812] [bug#59164] Coding style: similarly-named variables, Maxim Cournoyer, 2022/11/21
- [bug#58812] [bug#59164] Coding style: similarly-named variables, zimoun, 2022/11/22
- [bug#58812] [bug#59164] Coding style: similarly-named variables, Ludovic Courtès, 2022/11/26
[bug#58812] [PATCH 0/5] Add --symlink option to 'guix shell'., Ludovic Courtès, 2022/11/09