Closed fade2black closed 3 years ago
@simonsan ready for review
Do we only have dynamic dispatch examples?
@pickfire Do you mean by examples real examples like actix? In my code the second approach with function pointers doesn't use dynamic dispatch. As for real life examples, I haven't yet come across. If you know please share.
Not sure if like actix but I only see dyn xxx
stuff, we didn't show a method with static dispatch, which probably could be done using enum.
@pickfire I would merge it for now or do you want to add an example with static dispatch?
@simonsan I'll add a couple of sentences as you suggested. I'll have a look this evening (in 5 hours).
@simonsan I'll add a couple of sentences as you suggested. I'll have a look this evening (in 5 hours).
ok ;)
@pickfire I would merge it for now or do you want to add an example with static dispatch?
Up to you, I am lazy to do that currently. One way it could be done is to use enum handle multiple cases rather than a Box.
@pickfire I would merge it for now or do you want to add an example with static dispatch?
Up to you, I am lazy to do that currently. One way it could be done is to use enum handle multiple cases rather than a Box.
If we don't do it in this PR we can definitely reference that in a new issue for other people to add. :)
Looks fine for me 👍🏽 Let's wait till @pickfire and @MarcoIeni also gave their feedback and we're ready to merge. :)
@simonsan @pickfire I agree. Enum is a one way to address the delegation (to commands). I think enums should be added too. I might add it too a bit later. However, there is also a simple trade off between dyn traits and enums. If delegation occurs externally (crates for example), then trait objects would suit better, since we don't know in advance what kind of type a user may come up with. Like in actix. But if we are going to use it in our own application then since we control the enum variants and if add new variants not too frequently, we could use enum.
@simonsan @pickfire I agree. Enum is a one way to address the delegation (to commands). I think enums should be added too. I might add it too a bit later. However, there is also a simple trade off between dyn traits and enums. If delegation occurs externally (crates for example), then trait objects would suit better, since we don't know in advance what kind of type a user may come up with. Like in actix. But if we are going to use it in our own application then since we control the enum variants and if add new variants not too frequently, we could use enum.
Sure, I think at this stage it would be better to add it later in another PR, when more people had the chance to read over it after publishing and maybe also work in other feedback then, what do you think?
@simonsan @pickfire I agree. Enum is a one way to address the delegation (to commands). I think enums should be added too. I might add it too a bit later. However, there is also a simple trade off between dyn traits and enums. If delegation occurs externally (crates for example), then trait objects would suit better, since we don't know in advance what kind of type a user may come up with. Like in actix. But if we are going to use it in our own application then since we control the enum variants and if add new variants not too frequently, we could use enum.
Sure, I think at this stage it would be better to add it later in another PR, when more people had the chance to read over it after publishing and maybe also work in other feedback then, what do you think?
I agree.
@MarcoIeni Removed liftetimes from function ptrs.
Thanks :)
WIP
Fixes #248 Fixes #228