[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: |
Thu, 17 Nov 2022 19:44:18 +0100 |
Hi,
On Thu, 17 Nov 2022 at 18:37, Ludovic Courtès <ludo@gnu.org> wrote:
>> It's a pattern I've used at other places; I find it more hygienic to not
>> shadow existing variables; it signal to the reader "be careful, this is
>> not the same as the argument-bound one, though they are closely
>> related".
>
> I don’t buy it. :-) The reader might be careful yet end up using the
> “wrong” variable. As long as the “wrong” variable has no use, I think
> it’s best to shadow it so that mistakes cannot happen.
>
> Of course the details vary depending on context, but I think we should
> not start introducing this pattern in different places. Perhaps
> something to discuss and codify under “Formatting Code”?
I agree with Ludo. For another instance than target*, the previous was,
--8<---------------cut here---------------start------------->8---
((new '-> old)
[...]
- (symlink old (string-append target new)))
[...]
- (delete-file (string-append target new))
--8<---------------cut here---------------end--------------->8---
then replaced by,
--8<---------------cut here---------------start------------->8---
((new '-> old)
[...]
+ (let ((new* (string-append target* new)))
[...]
+ (error (format #f "symlink `~a' points to nonexistent
\
+file `~a'" new* old)))))
+ (symlink old new*))
--8<---------------cut here---------------end--------------->8---
Well, it seems a Star War. ;-) As Ludo, I am not convinced that it is
less error-prone, maybe the contrary.
Cheers,
simon
- [bug#58812] [PATCH v3 2/4] install: Validate symlink target in evaluate-populate-directive., (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 <=
- [bug#58812] [bug#59164] Coding style: similarly-named variables, Maxim Cournoyer, 2022/11/18
- [bug#58812] [bug#59164] Coding style: similarly-named variables, zimoun, 2022/11/21
- [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