vvvv / VL-Language

The official repo for the design of the VL programming language
31 stars 0 forks source link

[Workaround proposal] Enum Switch via Dictionary #55

Open gregsn opened 2 years ago

gregsn commented 2 years ago

grafik

This is a workaround proposal that covers #14.

enum switches using delegates and dictionaries.zip

It surprised me a bit

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 commented 2 years ago

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