ATOMIC AI ITERATIONS SPEC (EN) SCOPE RULE: This document defines the complete and binding iteration system of the Atomic language. RULE: Iterations in Atomic are syntactic constructs. RULE: Iterations are not functions. RULE: Iterations do not return values. SUPPORTED ITERATION CONSTRUCTS RULE: Atomic supports only the following iteration constructs: ripeti per volte ripeti finché RULE: This list is closed. RULE: No other iteration construct exists. RIPETI PER CONSTRUCT RULE: The construct ripeti per volte executes a block of code a finite number of times. RULE: It is conceptually equivalent to a counting loop. SYNTAX OF RIPETI PER RULE: The syntax is: ripeti per volte { code } RULE: The block delimited by curly braces is mandatory. BEHAVIOR OF RIPETI PER RULE: is a numeric expression. RULE: The value of is evaluated exactly once, at loop entry. RULE: If is less than or equal to 0, the block is never executed. RULE: The block is executed sequentially for the specified number of iterations. RULE: The loop terminates automatically after the last iteration. PREDEFINED ITERATION VARIABLE RIPETIZIONE RULE: Inside ripeti per, the predefined variable ripetizione exists. RULE: Properties of ripetizione: numeric type initial value is 1 automatically incremented at each iteration takes consecutive values up to the total number of repetitions read-only exists only inside the ripeti per block RULE: ripetizione does not exist outside the loop. RIPETI FINCHE CONSTRUCT RULE: The construct ripeti finché executes a block of code while a condition is true. RULE: It is conceptually equivalent to a conditional loop. SYNTAX OF RIPETI FINCHE RULE: The syntax is: ripeti finché { code } RULE: The block delimited by curly braces is mandatory. BEHAVIOR OF RIPETI FINCHE RULE: is a logical expression producing true or false. RULE: The condition is evaluated before each iteration. RULE: If the condition is false at the beginning, the block is never executed. RULE: The loop terminates when the condition becomes false. RULE: It is the responsibility of the code to make the condition false. RULE: Atomic does not automatically interrupt infinite loops. CONDITION CONTENT RULE: The loop condition may include: variables predefined variables mathematical expressions logical operators comparison operators DIFFERENCE BETWEEN RIPETI PER AND RIPETI FINCHE RULE: ripeti per volte: number of iterations is known at loop entry repetition count is evaluated once provides an automatic counter (ripetizione) RULE: ripeti finché: number of iterations is not known in advance condition is re-evaluated at each iteration no automatic counter exists ITERATIONS AND FRAME MODEL RULE: Atomic uses a frame-based execution model. RULE: Iterations are executed entirely within a single frame. RULE: Iterations do not introduce any notion of time. RULE: If an iteration is inside CICLO CONTINUO: it is executed again entirely at every frame RULE: If the program does not explicitly define events: iterations are executed inside the implicit CICLO CONTINUO VARIABLE SCOPE AND ITERATIONS RULE: Atomic does not enforce a strict lexical scope. RULE: Variables defined before a loop are accessible inside the loop. RULE: Variables defined inside a loop exist in the current execution context. RULE: The variable ripetizione is an exception: it is local to ripeti per it does not exist outside the loop ACCENT-FREE FORM RULE: For keyboard convenience, the form ripeti finche (without accent) is accepted. RULE: ripeti finche is fully equivalent to ripeti finché. RULE: No other textual variants exist. UNSUPPORTED ITERATION FEATURES FORBIDDEN: break continue do-while ripeti mentre ripeti fino a loops with declared index variables implicit or time-based loops FORMAL CLOSURE RULE: The iteration system of Atomic is limited to what is described in this document. RULE: Any undocumented iteration construct: is invalid is not part of the Atomic language