Skip to content

fix(post): state the one definition rule of the hookless clone mixin - #266

Merged
filipsajdak merged 1 commit into
mainfrom
fix/clone-series-odr
Nov 9, 2026
Merged

filipsajdak merged 1 commit into
mainfrom
fix/clone-series-odr

Conversation

@filipsajdak

Copy link
Copy Markdown
Contributor

Episode 4 gains a short section: every translation unit must see the same classes in the searched namespace, or the hookless clone() differs between units for the same specialization. From a review of the old repo's port, which now guards it with a two-unit test and a mutant twin. Prose-lint clean, production build exits 0.

Generated with Claude Code

Episode 4 now says every translation unit must see the same classes in the searched namespace, from a review of the old repo's port, and that the port checks it with a two-unit test.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 9, 2026 23:35
@filipsajdak
filipsajdak merged commit aeda040 into main Nov 9, 2026
3 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The post needs to clarify that another namespace can contain a separate closed hierarchy but cannot extend the original base’s clone dispatch, which still throws for the out-of-namespace derived class.

1 open issue
What changed in this PR

This documentation-only update clarifies the one definition rule requirement for Episode 4's reflection-based, hookless clone mixin.

Changes:

  • Adds a cross-reference from the namespace-search explanation to the new section.
  • Explains the need for consistent class sets across translation units, possible failure symptoms, and the port's two-unit verification test.
File Description
src/​content/​posts/​2026-12-21-std-polymorphic-instead-of-clone.mdx Documents cross-translation-unit consistency requirements for the hookless mixin.

Review effort: Balanced


## One definition rule for the hookless mixin

Every translation unit of a program must see the same classes in the searched namespace, so the hierarchy belongs in one header. A unit that sees a different set generates a different `clone()` for the same specialization, which is undefined. It can show up as `clone_unavailable` for a class the caller can see. The way to extend the set is another namespace. The 2014 repo's port checks the requirement with a test that links two translation units and compares the class lists each one sees.
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