Icon+Unicon/Intro: Difference between revisions

Line 247:
 
====suspend expr====
DefaultSuspend valueis ofsemantically exprsimilar isto 'return'&null''. Anywith procedurethe containingexception thethat ''suspend''it commandsets willup yieldthe apossibility valueof toproducing theadditional callingresults codeif needed. However Rather than terminating the procedure remainsas inreturn adoes, statesuspend ofreturns suspendeda animationresult readywhile toleaving bethe reactivatedprocedure ifin suspension in the callingevent codeadditional demandsresults anotherare resultneeded. due toA Goalsuspended Directedprocedure Evaluationwill resume at the next point in the code. Note that thisThis capability is built directly into the runtimerun time rather than being an artificially constructed behaviour provided by Python or C#'s use of the 'yield' keyword. Every and all expressions may suspend or be involved in a suspending expression without any effort. Behaviorally muchthis is closer to Prolog which also supports backtracking as a core part of the language. If the ''expr'' is capable of yielding more than one result, then suspend (if driven) will progressively yield all of those values.
 
A procedure can contain several uses of ''suspend'' and it's quite reasonable for the procedure to execute many of them in any chosen order.
Anonymous user