VL-Language icon indicating copy to clipboard operation
VL-Language copied to clipboard

[Proposal] Switch Region

Open sebllll opened this issue 5 years ago • 5 comments

For #14 we could use the same regions that are used in other situations like TryCatch:

image

Pros

  • same syntax as in other regions
  • visually clear. the use of horizontal space makes sense in a general vertical oriented graph

Cons

  • might get messy with large switch-case regions with many conditions
  • regions with "many colors" are tedious to use at the time of this writing. (needs manual asigning of each node or iobox)

sebllll avatar Nov 25 '20 16:11 sebllll

I like this idea for smaller examples, but for larger ones I would turn to a dictionary. Dictionaries are a little more complicated to setup, though.

String Switcher as Dictionary

How would you add extra conditions?

YanYas avatar Dec 31 '20 14:12 YanYas

well, this is just one proposal for the quest #14. and this proposal only focusses on how a switch-case could face the user. internally this visual representation should translate to a switch-case - or even to some if statements (iirc switch-case is also just syntax sugar for lot of if statements).

sebllll avatar Jan 05 '21 16:01 sebllll

Fair play, I think it would be more readable. And I just came across a situation where I think something like it could be handy: OnnxFromScratch6-TryTheseRuntimes-GPU Acceleration

I'm trying to create a 'fallback' system that prioritizes one option but will pick the next if there is an error. I suppose the internal logic a bit different though.

What I wonder is what would be the best way to add the new pins/cases to the node without it meaning a lot of extra clicks. This may mean a UX expansion to a ad not only one pin but a several at once.

YanYas avatar Jan 18 '21 18:01 YanYas

Your proposal is very much like what we always had in mind: moments for all of the cases. However, we didn't have in mind that you'd still need to check via a = operation since the moment already represents the case and is named by it. If you look inside the ADSR patch you can see this region: grafik It basically illustrates what we had in mind.

A nice to have would be output border control points in order to output not just one value. We once discussed an IfElse region - which should be very similar to an enum switch with two cases - that allows writing into the output border control points by linking to that BCP from both moments: true/false or if/else. Being able to link into output BCPs from different moments is touched here: #53 That said, with a bigger switch statement this way of expression could again get visually annoying, especially if you have more than one BCP: crossing links...

And then there are still issues in terms of readability and workflow. If the = and the ioboxes are missing then you need to hover all cases or put comments. And it is indeed still hard to patch in those type of regions, but you could argue that these should get fixed anyway.

Still not sure about the ideal solution.

Meanwhile, please have a look at #55 as a workaround.

gregsn avatar Feb 04 '22 00:02 gregsn

I like this idea for smaller examples, but for larger ones I would turn to a dictionary. Dictionaries are a little more complicated to setup, though.

regarding the Dictionary approach: thanks for bringing it up! I just stumbled upon the Cons [Dictionary] again: that way they are not so hard to set up. see #55 Let's discuss this approach over there

gregsn avatar Feb 04 '22 00:02 gregsn