Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require #[derive(Component)] for component types #27

Merged
merged 4 commits into from
Oct 1, 2021

Conversation

Frizi
Copy link
Contributor

@Frizi Frizi commented Jun 15, 2021

rfcs/27-derive-component.md Outdated Show resolved Hide resolved
rfcs/27-derive-component.md Outdated Show resolved Hide resolved
rfcs/27-derive-component.md Outdated Show resolved Hide resolved
rfcs/27-derive-component.md Outdated Show resolved Hide resolved
rfcs/27-derive-component.md Outdated Show resolved Hide resolved
@cart
Copy link
Member

cart commented Jun 15, 2021

I'd like it if the RFC compared "api design choices" a bit more:

Co-authored-by: MinerSebas <66798382+MinerSebas@users.noreply.github.com>
Copy link
Member

@alice-i-cecile alice-i-cecile 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 compelling enough for me as is, and I agree with everything stated in it.

@Ixentus
Copy link

Ixentus commented Jun 15, 2021

I agree with everything in this RFC about #[derive(Component)]. It offers a ton of benefits.

I don't like #[component(storage = "SparseSet")]. #[derive(Component)] is alright since most Components have derives anyway, but this storage one doesn't seem necessary. It looks like cart has some alternatives for this. Perhaps this change could be removed from the RFC and moved to a new issue, so the RFC can be accepted easily.

@alice-i-cecile
Copy link
Member

@Ixentus the new component storage configuration approach is much nicer than the old strategy. It will remain an optional optimization; simply omitting any configuration will use the default table storage.

@wilk10
Copy link

wilk10 commented Jun 16, 2021

Coming from a user perspective, I'd like to add that I really don't mind the (limited) extra boilerplate. More than once I found myself scanning through my structs wondering: "Is this a Component?", so besides the technical benefits listed above, I would enjoy the (already mentioned) visual indication at first glance as well.

@NathanSWard
Copy link

More than once I found myself scanning through my structs wondering: "Is this a Component?

I agree. This is one of the big upside to this RFC that is also really like.

Something else, I would like a world where change detection has an opt-out path, but that'll only be possibly once we have #[derive(Component)] and #[derive(Resource)]

Copy link
Member

@BoxyUwU BoxyUwU left a comment

Choose a reason for hiding this comment

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

I'm not sold on #[component(storage = "SparseSet")] but other than that I quite like this, personally I'd consider not having derive(Component) to be a blocker for relations

@NathanSWard
Copy link

I'm not sold on #[component(storage = "SparseSet")]

@BoxyUwU I'm curious about what part of this you're not sold on. Is it the static storage type, the syntax, etc...?

@BoxyUwU
Copy link
Member

BoxyUwU commented Jun 26, 2021

ah sorry yes should have clarified, it's just the syntax yeah. not a fan of using a string here and it's also a lot of text to write out. I'm not familiar with proc macros though so have no idea how actionable that is. Either way the proposed syntax seems totally workable and I wouldn't hate writing it :)

@Frizi
Copy link
Contributor Author

Frizi commented Jun 26, 2021

I actually tried without the string, but that would be kinda non-standard. The attribute parser provided with syn crate only allows literals at that position. We could roll our own if that's really desired, but it's just more work and definitely less common pattern.

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
@Ixentus
Copy link

Ixentus commented Jun 29, 2021

Thanks for that write-up @alice-i-cecile , I am now much happier with this DSL macro.

@cart
Copy link
Member

cart commented Oct 1, 2021

I think this is probably good to go. I do wish this was a bit more prescriptive about implementation details (ex: what should the Storage associated type look like? How will that be consumed in things like Fetch impls? Will Component::Storage be constrained to a Storage trait?)

But i've also dragged my feet on this enough and we do have an implementation that we all like.

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.

8 participants