moodymudskipper / flow

View and Browse Code Using Flow Diagrams
https://moodymudskipper.github.io/flow/
Other
395 stars 26 forks source link

could there be a special representation for "if x then stop" ? #32

Closed moodymudskipper closed 3 years ago

moodymudskipper commented 4 years ago

of "if x then single call instruction"

these offset the full diagram to the right, and I think they'd be more readable on one line, but not sure how it would work.

nomnoml won't allow horizontal arrows but we can be "close enough"

#.one: visual=hidden stroke=#fdf6e3

[previous code] -> [cond]
[<one> cond|
  [<choice>if (condition)]
  [<label> stop message]
  [<end> end1]
]
[cond] -> [next code]

image

Not super pretty, maybe not that useful in most cases, but some scripts start with a lot of checks and maybe it'd be handy, possibly as an option.

Would need to define how it would look in debug function as here there are no border nor arrow to dash

moodymudskipper commented 4 years ago

Actually this work and is much better!

[previous code] -> [<choice>if (condition)]
[<choice>if (condition)] -> [stop("message")]
[stop("message")] -> [<end> end1]
[<end> end1] -/- [next code]
[<choice>if (condition)] -> [next code]
[next code] -> [...]

image

Just draw an invisible segment rather than no segment at all

moodymudskipper commented 3 years ago

This was implemented using a narrow boolean argument, maybe some other name would be better, like squeeze, or column...

This makes the diagram longer and narrower obviously, but actually opens an opportunity for diagrams on several columns, to fit more on one screen. Indeed without a touch screen, big or even normal diagrams are less easy to manipulate.

narrow could be the number of columns. In that case narrow = TRUE would be naturally equivalent to narrow = 1.

The argument still needs to be implemented in all functions, only flow_view and flow_data so far.

This is link to another possible parameter, all if blocks (and for, while, repeat) end with an "end node". I believe it's important to keep for for while and repeat but might be good to skip for if in some cases (especially for narrow diagrams), as it takes up non trivial space, the default might end_if_node = !narrow.

It's a bit more tricky than narrow to implement, the argument name is not great and the value might not be huge (adding args is also adding confusion), so let's let this idea rest a bit.

moodymudskipper commented 3 years ago

lots of trouble for probably not much value

github-actions[bot] commented 2 years ago

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary.