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

[Workaround proposal] Enum Switch via Dictionary #55

Open
gregsn opened this issue Feb 4, 2022 · 1 comment
Open

[Workaround proposal] Enum Switch via Dictionary #55

gregsn opened this issue Feb 4, 2022 · 1 comment

Comments

@gregsn
Copy link
Member

gregsn commented Feb 4, 2022

grafik

This is a workaround proposal that covers #14.

enum switches using delegates and dictionaries.zip

It surprised me a bit

  • how handy the Cons [Dictionary] node really is
  • how handy the fact that delegate regions automatically pick up the name from the pin below - which in our case is the name of the enum entry
  • how relatively clean the patch is. both for complete and incomplete switches
  • and how relatively fast the pattern can be applied

Maybe we just need a complete enum switch automatically created by the VL system.
But note: the incomplete switch really looks handy as well, which can't be covered by the system.

@sebllll
Copy link

sebllll commented Feb 16, 2022

i like this clean approach very much!
only the automatic name pick up doesn't work in all cases.

one question that came up while looking at this was if it come with a performance penalty, when compared to switch-case?
And of course we need a possibility to create and edit enums, but that is already on the agenda iirc.

So, from my side this is a proper solution. For release i guess it deserves some syntax sugar like auto-creation of enums or so.

And: not every switch-case deals with enums, that's why i played a bit with the patch and added some more tests:
enum switches using delegates and dictionaries.zip

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

2 participants