Re: [PATCH] describe: fix --no-exact-match
- From
René Scharfe <l.s.r@web.de>
- Date
- Aug 10, 2023, 19:45 UTC
- Message-ID
- <b5fcc572-c710-5869-7a40-ba784d8edf0e@web.de>
- In-Reply-To
- <xmqqo7jfk8xq.fsf@gitster.g>
Am 10.08.23 um 03:00 schrieb Junio C Hamano:
Show 12 quoted lines
> Jeff King <peff@peff.net> writes:
>
>> int my_foo;
>> ...
>> OPT_CALLBACK('f', "foo", int, &my_foo, ...etc);
>>
>> Not great, but it might not be _too_ bad given that most helpers like
>> OPT_BOOL() can just say "int" behind the scenes.
>>
>> That said, I don't recall these void pointers being a large source of
>> errors in the past. So while it's a fun type-system puzzle, the
>> effort/reward ratio might not be favorable.I have vague memories of changing a callback from using a string_list to a strset (or whatever) and getting crashes out of some other callers that used it non-obviously via some macro. A compile-time check would have helped me.
> I tend to agree on both counts, it is a fun puzzle, and it probably > is not going to give us sufficient reward. The fact that "int" and > typeof(my_foo) need to be manually kept straight defeats the "type > safety" justification for this mental exercise.
The many-pointers idea is a bit silly, admittedly.
Having to declare a type manually is how most of C's type safety works, though, so a certain amount of that is unavoidable.
typeof (along with typeof_unqual) is nice, but I guess it will take a few years (or decades?) before we can expect it to be supported by all relevant platforms.
The typed-callback-with-void-wrapper idea seems promising. Let's see if we can get it into usable shape.
René