From: Junio C Hamano Date: Fri, 27 Oct 2023 23:12:20 GMT Subject: Re: [PATCH v5 1/5] bulk-checkin: extract abstract `bulk_checkin_source` Message-ID: In-Reply-To: <20231025073736.GB2145145@coredump.intra.peff.net> Jeff King writes: > Alternatively, I think some of our other OO code just leaves room for > a type-specific void pointer, like: > > struct bulk_checkin_source { > ...the usual stuff... > > void *magic_type_data; > }; > > and then the init_bulk_checkin_source_from_fd() function allocates its > own heap struct for the magic_type_data field and sticks the int in > there. Yup. All the pros-and-cons makes sense. I earlier said I found this a good place to stop, exactly because the full OO with struct specific_subclass { struct vtbl *vtbl; struct base_class common_data_specific_to_instance; ... other instance specific data members here ...; } would require us to add too many supporting infrastructure struct types; with only a few subclasses in use, it is a bit too much to justify.