Foobar and Foobaz and Barbaz, oh my!

From Esolang
Jump to: navigation, search
For the definition of the word foobar, see Wikipedia:Foobar

Foobar and Foobaz and Barbaz, oh my! is a simple esolang by User:Ihope127. The syntax is as follows:

Statement: "<identifier> and <identifier> and <identifier>, oh my<variable>"
Identifier: A nonnegative integer or a variable
Variable: "!" or "?" or "." or "..."

A statement of the form "A and B and C, oh myD" calculates ((A and B) or (C and D)) and stores the result in D.

? is a special variable in that reading from it produces input from the user rather than ?'s value, thus making ? effectively read-only as a variable. Likewise, . produces output, and though it can be used as a normal variable, anything written to it is also output to the screen. ... is also special: it's the instruction counter. In fact, only ! is a "normal" variable at all.

An example program:

? and 255 and 0, oh my.
0 and 0 and 0, oh my...

First, user input (?) is AND-ed with 255, which, assuming input is done with ASCII (for Unicode, use 2097151 instead of 255), simply returns ?. Then whatever is stored in . is AND-ed with 0, which will always produce 0. Then we are left with (? or 0), which produces ?. This value is then stored in ., thus outputting it. Next, "0 and 0 and 0, oh my..." is executed. Since 0 and anything is 0, this reduces to (0 or 0), which is 0, a value which is then stored in ..., producing a jump back to the first instruction.

Assuming input is bounded from the start, Foobar and Foobaz and Barbaz, oh my! is a finite-state machine with memory that is bounded at runtime, that is, a programmer can have as much memory as he/she wants, but he/she has to choose a value and stick with it while running the program.

ihope says the purpose of this language was to find out what the original phrase was.

A sample program that demonstrates Foobar's "switch instruction" can be found in the external resources section. It is 512 lines long, and half of it consists of the "jump bank" used for switching. Since all the information you need has to be stored in a single variable, and each case has to be tested separately (INTERCAL's operators would actually come in quite handy here), a "real" Foobar program has the potential to be extremely long. Nevertheless, this should be proof that Foobar is usable.

A cat program, which handles EOF=-1 is as follows:

? and 255 and 0, oh my!
! and 255 and 0, oh my.
! and -1 and 0, oh my...
(followed by 249 copies of '0 and 0 and 0, oh my...')

See also

External resources