On Mon, Aug 10, 2026, at 12:06 PM, Andrea Pinski wrote:
> I am still not a fan of this being a typeless argument; lambdas being
> a "typeless" argument
> Can we change this into say:
> ```
> template<typename T>
> static void
> for_each_env_path (const char *value, char *(*callback)(const char*, T
> *), T *data)
> ```
> Instead?
> Yes that means not using lambdas but I think it is more explicit and
> yes it is not "C++ style". It also forces captures to be much more
> explicit.
> Yes it means structs need to be written out.
> But it is typesafe and moreover it is easier to figure out what
> arguments should be passed to the callback. (I wish C++ syntax for
> callbacks and lambdas allowed for this better).

I could...but I feel this would be a severe degradation in readability.
Yes, it makes some of the low-level memory management details more
explicit, but it does so at the cost of making a mess of the actual
"business logic" --- one has to scroll up to find the callback function
and the struct holding its data, rather than reading everything inline.

I know GCC is not Clang, but given that none of this driver is very
performance sensitive, while its actual behavior is quite key in
determining how hard countless downstream build systems have to work, I
would if anything prefer to go in the other direction: gutting all the
C-style string manipulation in the driver in favour of using C++
standard library features to make it much terser. (I suppose this gets
more attractive with C++17 or later, though, and GCC only just bumped to
C++14.)

I certainly don't mean to die on a "good C++ style" hill --- I have no
particular fondness for that language --- my bias here, as a
professional Haskell programmer for many years, is that lambdas "going
mainstream" is one of the greatest things to happen to mainstream
languages in the past decade, and a massive ergonomic benefit that I
would be disheartened to give up.

Anyway, ignoring my own opinions: it seems there is some difference of
opinion among the maintainers as to what style should be used in the
driver. The other people I emailed were involved in landing some of the
patches in the last series with the C++isms. Maybe it would be good for
you all to settle on a direction? I am happy to follow the consensus,
whatever it may be. I just want to make sure I am not doing one style
for one person and another style for another.

I hope that's an understandable sentiment coming from me.

Thanks,

John

Reply via email to