Jim Porter
2018-10-18 00:24:54 UTC
P1203: Modular Main looks like it addresses a concern I had with modules
quite some time ago[1]; specifically, whether you can define a "generic
main()" in a module-based library to use, instead of forcing users to
write their own main(). However, since the paper is fairly brief, and I
haven't followed the modules work closely, I wanted to confirm whether
this scenario would be supported by P1203.
My use case is primarily for providing a generic main() function for a
unit testing framework to allow users of the framework to avoid having
to write their own. Currently, I inject the main() via an #include
statement, and all the user-written tests are defined within static
globals[2].
It may turn out that this method has other issues when used with
modules, but I wanted to see if it's even possible under P1203. As the
paper wisely notes, tests for a module probably need to live *within*
that module in order to see non-exported names. However, initializing
your tests within the constructors of static globals would cause them to
be created even when merely *using* the module. Perhaps there's an easy
alternative here that retains the expressiveness of my current solution,
but I'm not sure what it would be just yet...
- Jim
[1]
https://groups.google.com/a/isocpp.org/d/msg/modules/naaN9T3cmMM/oeT1Ig7WaTYJ
[2]
https://github.com/jimporter/mettle/blob/master/examples/test_01_basic.cpp
quite some time ago[1]; specifically, whether you can define a "generic
main()" in a module-based library to use, instead of forcing users to
write their own main(). However, since the paper is fairly brief, and I
haven't followed the modules work closely, I wanted to confirm whether
this scenario would be supported by P1203.
My use case is primarily for providing a generic main() function for a
unit testing framework to allow users of the framework to avoid having
to write their own. Currently, I inject the main() via an #include
statement, and all the user-written tests are defined within static
globals[2].
It may turn out that this method has other issues when used with
modules, but I wanted to see if it's even possible under P1203. As the
paper wisely notes, tests for a module probably need to live *within*
that module in order to see non-exported names. However, initializing
your tests within the constructors of static globals would cause them to
be created even when merely *using* the module. Perhaps there's an easy
alternative here that retains the expressiveness of my current solution,
but I'm not sure what it would be just yet...
- Jim
[1]
https://groups.google.com/a/isocpp.org/d/msg/modules/naaN9T3cmMM/oeT1Ig7WaTYJ
[2]
https://github.com/jimporter/mettle/blob/master/examples/test_01_basic.cpp
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/4b4d0424-8b26-5584-d431-36d2b868e382%40gmail.com.
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/4b4d0424-8b26-5584-d431-36d2b868e382%40gmail.com.