On Wed Nov 19, 2025 at 12:08 AM JST, Timur Tabi wrote:
> On Tue, 2025-11-18 at 22:04 +0900, Alexandre Courbot wrote:
>> On principle, I tend to agree. In practice, we will probably never have
>> more than these two variants, so we need to balance the benefit of a
>> trait against the overhead of defining it in the first place (there are
>> quite a few methods in there).
>> 
>> Trait objects come with their own complications, i.e. you need to store
>> them on the heap if you need more than a short-lived reference - but in
>> our case the short-lived reference should be what we need anyway.
>
> So I would prefer not to rewrite everything, especially since you did tell me 
> early on than an
> enum was the right approach.

I cannot know the right approach early-on, all I do is provide
directions to explore, then we can focus on the one that looks the most
promising as we understand the shape the code is taking. If it turns out
it is not the one currently in use in the early patches, of course we
will adapt the code.

In this particular case using an enum still looks correct to me (mostly
because a trait object would probably end up requiring more code), but
there are other instances in the patchset where we will need to tune
the direction a bit now that we see the bigger picture.

Reply via email to