Skip to content

Avoid saying temper in temper-built c++#454

Merged
tjpalmer merged 2 commits into
mainfrom
cpp-stop-temper-namespace
Jul 7, 2026
Merged

Avoid saying temper in temper-built c++#454
tjpalmer merged 2 commits into
mainfrom
cpp-stop-temper-namespace

Conversation

@tjpalmer

@tjpalmer tjpalmer commented Jul 1, 2026

Copy link
Copy Markdown
Contributor
  • Libraries built by temper should just be libraries in whatever target language
  • Stop putting temper:: namespacing around user libraries
    • If we don't yet have c++ namespace config in config.temper.md, we can add that in the future
  • Also say global_init_... instead of temper_init_... to init user libraries

tjpalmer added 2 commits July 1, 2026 14:13
Signed-off-by: Tom <tom@temper.systems>
Signed-off-by: Tom <tom@temper.systems>
*
* All module-level variable initializations and init blocks are deferred to an explicit
* `temper_init_<module>()` function, called from `main()`, to avoid the Static
* `global_init_<module>()` function, called from `main()`, to avoid the Static

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also still need subnamespaces for submodules of libraries. Currently, they all go in the same namespace. I checked by looking at the output of object-literals funtest, but the convention above already shows the expectation of a shared namespace.

Once we split namespaces, maybe this would be just global_init or module_init in each module's own namespace.


// Compute the C++ namespace for the std library's Test type
val testNs = "temper::${safeCppNamespace(cppNames.library("std").text)}"
val testNs = safeCppNamespace(cppNames.library("std").text)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also looked at the output here, and the namespace we make for std is temper_std. So this was saying temper::temper_std and now just says temper_std. Perhaps we could say just temper::std in the future, but this PR is just a first pass on these things.

| void greet(std::string name) {
| temper::core::Console::log(console_0, "Hi:");
| temper::core::Console::log(console_0, name);
|namespace my_test_library {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now a namespace I'd be happy with users of my temper-built library using.

| x = 42;
|namespace my_test_library {
| int32_t x;
| void global_init_something() {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the backend test places this under a submodule called something. In the future, it would be nice to see my_test_library::something::global_init() or some such.

@tjpalmer tjpalmer marked this pull request as ready for review July 1, 2026 23:02
@tjpalmer tjpalmer requested review from ShawSumma and mikesamuel July 1, 2026 23:02
@mikesamuel

Copy link
Copy Markdown
Contributor

Agree with the goal. We shouldn't be "Sent from my iPhone"-ing translations of code that isn't related to the Temper project itself.

The implementation looks fine to me but @ShawSumma would know better.

@tjpalmer tjpalmer merged commit 44a15d2 into main Jul 7, 2026
2 checks passed
@tjpalmer tjpalmer deleted the cpp-stop-temper-namespace branch July 7, 2026 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants