yesworkflow-org / yw-prototypes

Research prototype with tutorial. Start here to learn about and try YesWorkflow.
http://yesworkflow.org/wiki
Other
33 stars 13 forks source link

Best practice for nested code? #34

Open olyerickson opened 8 years ago

olyerickson commented 8 years ago

I discovered "the hard way" a way to do nested code (loops, etc) --- inserting an @end before the next level, then inserting a @begin at the next level. This captures the fall-through (open loop?) logic but doesn't get the "spirit" of the nesting.

What do you recommend for representing nesting?

tmcphillips commented 8 years ago

You can model your script as a set of nested code blocks each delimited with @begin and @end. For example, the following (if each line appears in a comment) declares that block A contains block B which contains block C:

@begin A
@begin B
@begin C
@end C
@end B
@end A

Code can appear between any of the YW annotations above, and there can be multiple code blocks nested within any other code block. However, if the blocks aren't properly nested you'll get an exception.

Data flow between levels is achieved in the same way that workflow ports are connected to ports on code blocks at the top level of the workflow.