On Friday, 24 July 2026 22:27:34 Pacific Daylight Time EXT Tim Blechmann via
Development wrote:
> > Because this is a design question for the API: do we need a tag in the
> > first place? Or just a set of booleans?
>
> the tag is always a quality-of-life feature. it won't harm to also have
> booleans.
>
> an example how they compose:
> ```
> void foo(Os::UnixT);
> void bar(Os::UnixT);
> void bar(Os::DarwinT);
>
> template <typename OsType)
> void fooAndBar(OsType os)
> {
> foo(os);
> bar(os);
> }
> ```
I understand how tag dispatching works. I am asking for more concrete(ish) use
cases so we can judge whether we should add them at all (and open ourselves up
for bikeshedding discussion of just what the compositions should be), or
whether a set of booleans which are far easier to expand will suffice.
> one other example where i found tags useful is when the os that one
> targets, does not need to be the "current" os. it is not a common use
> case, though:
> ```
> void parseBinaries(string os)
> {
> if (os == "linux")
> parseBinaries(Os::Linux);
> else if (os == "macos")
> parseBinaries(Os::MacOS);
> [...]
> }
> ```
Ok, this is a good one because it would organise the OS-specific code in
parseBinaries functions, which are compiled for all OSes and this compile-time
checked. But why do you need tags for this? This could be parseLinuxBinaries()
and parseMacOsBinaries(). I suppose you may answer that the function might
actually be a parseBinaries(OS::Unix_t) and thus both branches call the same
function... but again, easy to fix without tags. And you've spent an
unnecessary runtime comparison because QString's comparEqual ends up in a non-
inline function.
Can we have a few more ideas where this would be used?
--
Thiago Macieira - thiago.macieira (AT) intel.com
Principal Engineer - Intel DCG - Platform & Sys. Eng.
smime.p7s
Description: S/MIME cryptographic signature
-- Development mailing list [email protected] https://lists.qt-project.org/listinfo/development
