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

Input vs. output types #3

Open
Benjamin-Dobell opened this issue Jul 29, 2020 · 1 comment
Open

Input vs. output types #3

Benjamin-Dobell opened this issue Jul 29, 2020 · 1 comment

Comments

@Benjamin-Dobell
Copy link
Owner

Benjamin-Dobell commented Jul 29, 2020

This was just briefly touched on in #2, with relation to tts__SnapPoint vs tts__SnapPointParameters.

However, TTS regularly has two sets of corresponding types for input and output within TTS' APIs. Take for example the object state type (ObjectState.def.lua). They're defined with optional fields and "plain old data" shapes, and represent the data you can feed into TTS spawnObjectJSON method (once serialised).

However, when you call getJSON() or getData() TTS will return a more concrete type, where every field is guaranteed to exist, having been populated with their default values. TTS also (typically) returns concrete Vector and Color types.

If we were to only have one, the input types are preferable, as the output types are compatible with the input types but not vice versa. However, I think long term we're going to have to bite the bullet and produce two sets of types (where appropriate). Chances are this will be a big breaking change.

Open to suggestions.

@Benjamin-Dobell
Copy link
Owner Author

Benjamin-Dobell commented Jul 29, 2020

ge_tts also runs into a similar problem and defines helper types using generics to keep things DRY. However, despite being shorter, I think the use of generics at scale just to avoid repeating one-self may complicate the types too much for casual observers. Just food for thought:

https://github.com/Benjamin-Dobell/ge_tts/blob/7ca6a01/Vector3.ttslua#L8-L16
https://github.com/Benjamin-Dobell/ge_tts/blob/7ca6a01/Vector3.ttslua#L43

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

No branches or pull requests

1 participant