In this case, the solution is simpler and was already
seen in Chapter 7. We can make a Label object connected to the start of the chain of
commands we want to jump to, and connect our GOTO to that object. Since GOTO
can only be connected to a Label object, we do not need to follow GOTOs recursively.
If we also forbid normal sequential ?¬‚ow to Labels, we can generate the program by
starting at all Labels that have no incoming relationships, and generating recursively
from each. Where we would have liked a Label to be part of the sequential ?¬‚ow, we
simply move it out and make that sequence call it via a GOTO.
Even this approach will only take us so far, just as it only took early programmers
so far. As programs grew, they found that they needed more advanced constructs.
However, such growth is by nomeans a certainty in DSM, andmay be a symptom of
trying to build a modeling language that mimics program language constructs,
rather than focusing on the problem domain. If the growth does occur, the next
logical step is GOSUB: GOTO with a return back to the same place. And following
hard on GOSUB??™s heels are its more familiar and powerful implementations:
functions.
Functions The problems of sequential generation, whether iterative or recursive,
are largely caused by the same object being reachable by more than one path.
Pages:
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538