User:Zzo38/Untitled 3

From Esolang
Jump to navigation Jump to search

There is a set of scheduled subroutine calls, each on a given turn number, counting from 0 being the current turn and positive numbers are in future. On each turn, all subroutine calls scheduled for that turn are executed (in any order), and then advance to the next turn. If something schedules a subroutine for the current turn then it will be executed before advancing to the next turn.

The program is a list of subroutines. Each subroutine is written by the name and then { and then the instructions and then } at the end. Put semicolons between the instructions, and you can have an optional semicolon after the last instruction.

A name consists of any digits, letters, and underscores, including none at all. (A blank name is the program starting call.)

Comments are starting with % and stop at the end of the line.

Possible instructions are:

  • name[expr] - Schedule a subroutine call the specified number of turns into the future.
  • expr=expr?name[expr] - Conditionally schedule, only if the first two values are equal.
  • expr/expr?name[expr] - Conditionally schedule, only if the first two values are unequal.
  • $expr - Output a number. During each turn the numbers output are unordered although are associated with the turn they belong to as well as with the subroutine that causes the output.

All schedules made during the current turn are not visible in expressions until the next turn; all expressions refer to only the beginning of the current turn.

Expressions can be:

  • Any natural number represented in decimal, or in hexadecimal with 0x at first. (Negative numbers are not allowed.)
  • <name - The earliest turn number that the specified subroutine is scheduled for, not counting the current turn. If there isn't any, then this instruction is skipped.
  • >name - The latest turn number that the specified subroutine is scheduled for. If there isn't any, then it is zero.
  • #name - The number of schedules of the specified subroutine for future turns, not counting the current turn.
  • (expr) - Parentheses grouping for binary operators.
  • expr+expr - Addition.
  • expr*expr - Multiplication.
  • expr^expr - Bitwise XOR.

There is no precedence, although the binary operators are associative (and commutative), so you do not need parentheses if you are using multiple same operators, but if using different operators then you do need parentheses.