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

type safe messaging? #161

Open
x37v opened this issue Sep 1, 2020 · 2 comments
Open

type safe messaging? #161

x37v opened this issue Sep 1, 2020 · 2 comments

Comments

@x37v
Copy link
Contributor

x37v commented Sep 1, 2020

I'm wondering if it might make sense to somehow make some of the messaging more type safe.

For instance, the dspsetup and dspstate messages could be virtual methods for the vector and sample dsp classes. These methods would have the actual signature of the args they expect instead of an atom list.

@tap
Copy link
Contributor

tap commented Sep 1, 2020

The reason that dspsetup was required to do this way is that we must have that method regardless of whether the object author creates/overrides it. In most other cases, if the user doesn't create it then nothing is needed at all.

However, having a way to define methods that are type-safe, leverage IDE auto-completion, and provide proper documentation about arguments is highly preferable.

For example, the means of delivering mouse events in UI objects and also the way notifications pass arguments are both currently suffering from some amount of trying to make every-differently-shaped-peg fit into a round hole.

@jonasohland
Copy link

I had a similar thought while poking around in the min-lib a while ago and decided to write a small proof-of-concept library myself.

It uses some scary preprocessor constructs and even more scary cxx17 template magic like compile time type introspection and if constexpr-stuff to find special methods defined on the users class and resolve calls from the external wrapper to these at compile time, with type-safety on the users side.

If don't think the approach is one that is realistic for the min-lib but if you find it interesting anyways please have a look at the library and some examples.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants