Re: [PATCH 04/10] string-list API: mark "struct_string_list" to "for_each_string_list" const
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Oct 27, 2022, 19:32 UTC
- Message-ID
- <xmqqlep1kqpy.fsf@gitster.g>
- In-Reply-To
- <patch-04.10-40b3cc9b8d4-20221026T151328Z-avarab@gmail.com>
Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
Show 12 quoted lines
> Add a "const" to the "struct string_list *" passed to > for_each_string_list(). > > This is arguably abuse of the type system, as the > "string_list_each_func_t fn" take a "struct string_list_item *", > i.e. not one with a "const", and those functions *can* modify those > items. > > But as we'll see in a subsequent commit we have other such iteration > functions that could benefit from a "const", i.e. to declare that > we're not altering the list itself, even though we might be calling > functions that alter its values.
The callback functions are allowed to (by taking a non-const pointer) modify the items, but are there ones that actually modify them?