Skip to content

BSN: changing prefixes for Template and SceneComponent to allow removing confusing "inheritance" concept#24367

Merged
mockersf merged 9 commits into
bevyengine:mainfrom
laundmo:bsn-prefix-shuffle
May 21, 2026
Merged

BSN: changing prefixes for Template and SceneComponent to allow removing confusing "inheritance" concept#24367
mockersf merged 9 commits into
bevyengine:mainfrom
laundmo:bsn-prefix-shuffle

Conversation

@laundmo
Copy link
Copy Markdown
Contributor

@laundmo laundmo commented May 20, 2026

Objective

Changes discussed with cart:

  • : will not be called "inheritance" anymore, but instead "cacheable" (name not final)
  • the Template patching prefix changes @ -> ~
  • the SceneComponent prefix changes : -> @
  • the : prefix is allowed in front of @SceneComponent as well, marking it as being cached

me: do we forbid caching of functions which take an argument?

cart: We should forbid it until we support it, and I don't plan on supporting this in the short term, as it adds new controversial design aspects to the system (building a mapping from parameters to cached scenes, ensuring the parameters are all hashable, etc).

Link to the discord thread, specifically my recap message.

The exact reasoning is in the linked discord discussion, but the tldr is:
"Inheritance" as a term for the ":" syntax didn't really fit what bsn was doing, since scenes without : produce the same result. All : is, is a way to say "cache this pls" with the design of bsn imposing the limitation that only the first scene can be cached

That was all fine, except for one case: Disambiguating SceneComponents from normal components. So if we redefine : to just mean "caching" we needed to untangle it from SceneComponents. That means disambiguating SceneComponents needed a different syntax, and the decision ended up being to take the @ prefix from the much less common @Template usecase, since SceneComponent {@prop: val} already used @ as well and introduce a new prefix to replace @Template instead, replacing it with ~Template.

Solution

Implement these changes in macros.

Notably, this still doesn't implement/enable caching right now.

Most docs are updated, except for the big blocks in bevy_scene/src/lib.rs and bevy_scene/macros/src/lib.rs since i've been working on reworking those on another branch and didn't want to duplicate whats already been a lot of work and likely to be a bunch more

Testing

  • bevy_scene tests passing
  • cargo check --workspace and cargo check --workspace --examples passing

Since this PR does not yet enable caching, I think passing the current tests should be enough.

@laundmo laundmo added A-Scenes Composing and serializing ECS objects S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged D-Macros Code that generates Rust code labels May 20, 2026
@laundmo
Copy link
Copy Markdown
Contributor Author

laundmo commented May 20, 2026

CI is expected to fail for a while, until all tests, uses, etc are migrated.

Will likely impact currently open PRs which use BSN, as it changes syntax, unless they don't use : with arguments or SceneComponents.

@laundmo laundmo marked this pull request as ready for review May 20, 2026 22:05
@laundmo laundmo requested review from cart and viridia May 20, 2026 22:05
@laundmo laundmo changed the title BSN: syntax changes discussed with cart, changing prefixes and get rid of confusing "inheritance" concept BSN: changing prefixes for Template and SceneComponent to allow removing confusing "inheritance" concept May 20, 2026
Copy link
Copy Markdown
Member

@cart cart left a comment

Choose a reason for hiding this comment

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

This is a solid step forward! Just pushed a minor tweak.

Comment thread crates/bevy_scene/macros/src/lib.rs Outdated
Co-authored-by: Carter Anderson <mcanders1@gmail.com>
@Zeophlite
Copy link
Copy Markdown
Contributor

Zeophlite commented May 21, 2026

From Discord :

I want to save -Thing for "removal patches"

~Thing
-Thing

These are visually very similar, it might be worth considering a different symbol as followup

Comment thread crates/bevy_scene/macros/src/lib.rs
Copy link
Copy Markdown
Contributor

@Zeophlite Zeophlite left a comment

Choose a reason for hiding this comment

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

i think this greatly improves developer intuition on the concept

@laundmo laundmo removed the request for review from viridia May 21, 2026 05:49
@alice-i-cecile alice-i-cecile added this pull request to the merge queue May 21, 2026
@alice-i-cecile alice-i-cecile added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged labels May 21, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch May 21, 2026
@mockersf mockersf enabled auto-merge May 21, 2026 15:07
@mockersf mockersf added this pull request to the merge queue May 21, 2026
Merged via the queue into bevyengine:main with commit 5897ed6 May 21, 2026
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Scenes Composing and serializing ECS objects D-Macros Code that generates Rust code S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants