[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#59164] Coding style: similarly-named variables
From: |
Ludovic Courtès |
Subject: |
[bug#59164] Coding style: similarly-named variables |
Date: |
Sun, 20 Nov 2022 11:46:00 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) |
Hi,
Maxim Cournoyer <maxim.cournoyer@gmail.com> skribis:
[...]
>>> 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.
>
> I'm surprised you're not buying it, given we're writing Scheme in a more
> functional style, and mutating same-named variables clearly goes against
> that style :-).
There’s no mutation here, only lexical scoping. Anyway, I find it clear
that the risk of typing ‘x’ instead of ‘x*’, especially in relatively
long functions, justifies shadowing in situations like this one. WDYT?
>> 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”?
>
> That's more of a coding style guidelines than "formatting" code
Sorry I meant “Coding Style”, which is the section that documents the
project’s conventions.
> (when I read "formatting", I think of a mechanical process like 'guix
> style' or 'rust-fmt' can do), but yes, that could be nice to have.
> Better yet, something basic to share across the whole Guile/Scheme
> community and include in the Guile user manual, like Python has PEP 8
> they can refer to, to save every Guile/Scheme project from having to
> reinvent the wheel.
I won’t do it, but sure, why not! My immediate concern is to make sure
we have a shared understanding, within Guix, of some of the conventions
we follow. It’s a minor issue, but minor issues are what our day-to-day
work is made of. :-)
Thanks,
Ludo’.
- [bug#58812] [PATCH v3 1/4] Makefile.am: Sort EXTRA_DIST entries., (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, 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