User:MDude/Countdown

From Esolang
Jump to navigation Jump to search

The main idea behind the language is to center everything around the moment designated as final, like a rocket launch or a bomb detonation. Everything is built up as a sequence leading up to it. When the code is run, it is given a time parameter that determines when the code will finish running. All flow control is directly or indirectly based on this time, because all control flow is based on time blocks. A time block is either the duration of the whole program, or the duration of the contents of a control flow statement. Either the end or start of the time block may be used as a reference. A time block is defined as follows:

#<program title or block name> <if block name, control flow statement goes here>
[
	<commands>
]

The count command runs near the end of a time block, the maximum duration of each command and set number of repetitions are used to set aside

#<block name> Countdown each within <non-negative integer> <unit of time>

Repeat is a simple loop that acts the same as listing its contents several times.

#<block name> Repeat <non-negative integer> times

For grouping purposed, Run runs exactly once.

#<block name> Run  within <non-negative integer> <unit of time>

It is important to assign time blocks wisely, as the language has no idea how long any individual command takes, only the time assigned for each block. When assigning time blocks, it will do so from the end of the parent block backwards. If a time block is too large to fit in its parent, it will be discarded. The or command allows you to define an alternate, shorter, block that can be potentially used as a substitute. In addition to being to long, there is an implementation-defined (and theoretically, though not practically) minimum time limit below which the a block will be skipped similarly to if it was too long.

Voice Output

Announce causes a synthetic voice to announce to announce the statement given, including static strings and variable values. A prerecorded voice may be implemented, but a proper countdown implementation is able to fall back on synthesis when an unrecorded word is encountered: Merely stating "[String of word[s] not found" would surely be insufficient.

Announce "String goes here" OrJustNameAVariable "no need for + when concatenating."


Examples

Here are a pair of examples of ninety nine bottles of beer, using a few commands not described above yet.

#Ninety_nine_bottles
[
	#Bottles Countdown 99 each within 9 seconds
	[
		Announce Count " bottles of beer on the wall, " count "bottles of beer!"
		Announce "Take one down and pass it around, " Count " bottles of beer on the wall!"		
	]
]	
complete
{
	Announce "No more bottles of beer on the wall, no more bottles of beer!"
	Announce "Go to the store and get some more, ninety nine bottles of beer on the wall!"
}
else
{
	Announce "System halted: No more time for beer!"
}
//Ninety Nine Bottles with an example of functions (not shown, but possible: recursion)

#Ninety_nine_bottles
[
	Bottles Countdown 99 each within 9 seconds
]	
complete
{
	Announce "No more bottles of beer on the wall, no more bottles of beer!"
	Announce "Go to the store and get some more, ninety nine bottles of beer on the wall!"
}
else
{
	Announce "System halted: No more time for beer!"
}

-

#Bottles 
[
	Announce Count " bottles of beer on the wall, " count "bottles of beer!"
	Announce "Take one down and pass it around, " Count " bottles of beer on the wall!"		
]

Note that in the above examples, "System halted: No more time for beer!" should never actually ever be displayed if there is any time to process at all, as the individual cycles of Bottles should be cut off if they go over time, and the completion state of a loop does not necessarily depend on the performance of its child loops.