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

Introduce symbols for property/signal names #40

Closed
7 tasks done
josephbirkner opened this issue Jan 18, 2019 · 3 comments
Closed
7 tasks done

Introduce symbols for property/signal names #40

josephbirkner opened this issue Jan 18, 2019 · 3 comments
Labels
core ⚙️ Issues that concern the core ravestate lib/API

Comments

@josephbirkner
Copy link
Collaborator

josephbirkner commented Jan 18, 2019

Currently, the lack of symbols for property/signal names has 3 drawbacks:

  1. unused import warnings for dependencies
  2. typos in property paths lead to errors
  3. forgetting dependencies

Therefore, the following set of ravestate API changes should be introduced:

  • §0 Properties may be constructed like my_prop = PropertyBase(...) in a with Module(...) clause, module scope is assigned automatically. Dependencies may then use my_prop.
  • §1 Signal can be constructed in with Module ... clause, module scope will be set automatically. Signal may be used as parameter signal=my_signal in state declaration
  • §2 Referring to signals by name should become illegal. The s(...) function will be removed. Refer either by exported module variable, or by the respective Property/State APIs.
  • §3 Setting Signal constraint properties like min_age, max_age, detached, will be moved from constructor parameters to chainable function calls: my_signal.min_age(30).detached(). Each function call returns a copy of the signal with the respective member value change.
  • §4 Properties will be referrable by symbols. The context's push/pop/setitem/getitem functions will be changed accordingly.
  • §5 It should be prevented, that developers call a property's read/write function directly. For this purpose, context should always adopt copies of the respective property objects. The originals will be untouched. An exception to this rule is generally made for child properties, since they mark an advanced use-case where properties are generally created dynamically, and usually accessed through their path anyway.
  • §6 The PropertyBase class will be renamed to Property.
@josephbirkner josephbirkner added core ⚙️ Issues that concern the core ravestate lib/API and removed enhancement labels Jan 28, 2019
@josephbirkner josephbirkner changed the title Introduce constants for property names Introduce symbols for property/signal names Feb 3, 2019
@josephbirkner
Copy link
Collaborator Author

@Toseban thoughts?

@Toseban
Copy link
Collaborator

Toseban commented Feb 27, 2019

I like it very much 👌
Would definitely make the code cleaner and less error prone to typos.

@josephbirkner josephbirkner mentioned this issue Apr 23, 2019
15 tasks
@josephbirkner
Copy link
Collaborator Author

Implemented with #86

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core ⚙️ Issues that concern the core ravestate lib/API
Projects
None yet
Development

No branches or pull requests

2 participants