Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

parameter_types! helper functions should be uniform across modes #13795

Closed
liamaharon opened this issue Apr 1, 2023 · 7 comments
Closed

parameter_types! helper functions should be uniform across modes #13795

liamaharon opened this issue Apr 1, 2023 · 7 comments
Assignees
Labels
J0-enhancement An additional feature request.

Comments

@liamaharon
Copy link
Contributor

The parameter_types works in 3 modes.

  1. static (generates thread_local stuff)
  2. storage
  3. const

All of which generate a Get implementation, backed by something, along some other helper functions like get, set, mutate and take (kinda similar to storage items..).

It seemed to me that the set of helper functions that is generated by parameter_types! is not uniform across different modes.

If interested, you can convert this comment into an issue and self-assign.

Originally posted by @kianenigma in #13794 (comment)

@ggwpez
Copy link
Member

ggwpez commented Apr 1, 2023

We and dowstream projects use those in many spots. Just having a breaking change here for beauty is not that of a good idea IMHO.
Unless we can stay backwards compatible. Maybe we can give all of them storage traits?

@liamaharon liamaharon added the J0-enhancement An additional feature request. label Apr 1, 2023
@bkchr
Copy link
Member

bkchr commented Apr 1, 2023

It seemed to me that the set of helper functions that is generated by parameter_types! is not uniform across different modes.

You can not give all of them uniform functions. const for example can not be set/mutated/taken. The static implementation for example also can not be "taken".

@kianenigma
Copy link
Contributor

What I originally suggested is entirely backwards compatible. It seemed that some functions are missing, and adding them would make the API more uniform.

@bkchr
Copy link
Member

bkchr commented Apr 14, 2023

And which are missing?

@liamaharon
Copy link
Contributor Author

From what I could gather, these are the differences in mode:

  • const: Generates a const getter function named get.

  • No prefix (non-const): Generates a non-const getter function named get.

  • storage: Generates getter and setter functions. It also generates a key function to get the storage key.

  • static: Generates getter and setter functions. It also generates thread_local code.

The differences in API between seem irreconcilable at first glance, e.g. it doesn't make sense for const to have a setter, or for the static mode to have a key.

@bkchr
Copy link
Member

bkchr commented Apr 20, 2023

The differences in API between seem irreconcilable at first glance, e.g. it doesn't make sense for const to have a setter, or for the static mode to have a key.

As I tried to explain above.

@kianenigma
Copy link
Contributor

Got it, I have jumped too fast at making it an issue them. Thanks for the explanation(s), closing.

@github-project-automation github-project-automation bot moved this from Backlog to Done in Runtime / FRAME Apr 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
J0-enhancement An additional feature request.
Projects
Status: Done
Development

No branches or pull requests

4 participants