esolang

Pinocchio

Every variable is a nose, and the only way to change it is to lie or to tell the truth.

that_dude · Turing complete: unknown · ●●○ moderate · esolangs.org

Tested with 4 known programs · Test method

Run it

Expected: H

The idea

that_dude built Pinocchio around the puppet whose nose grows when he lies. A program is a set of Pinocchios, which work like functions, and each one has a single variable, its nose. Any Pinocchio may look at another one's nose, but only the owner can change it, and only by making a claim. A lie makes the nose 1 longer and the truth makes it 1 shorter.

Read the story

There is no loop inside a Pinocchio. To repeat, it talks to Geppetto, its maker, who starts it over from the top. The nose stays as it was.

The machine

StatementDoes
yes(claim);The nose grows by 1 if the claim is false and shrinks by 1 if it is true
name.talk();Run another Pinocchio, then come back
Geppetto.talk();Start this Pinocchio over from its top
if (claim) { ... }Run the block when the claim holds; there is no else
print(name);Write that nose as a character

A claim is true, false, a number or name.nose, or two of them compared with ==, !=, < or >. me names the running Pinocchio, main runs first and every nose starts at 0. All Pinocchios are sane, so none of them may talk to itself.

Example

liar lies once each time main talks to it, and main starts over until the nose is 72, the code of H.

liar lies once each time main talks to it, and main starts over until the nose is 72, the code of H.

The specification's own example. liar claims that its nose is 65. That is a lie until the nose gets there, so it grows to 65 and stops, and truthseeker prints it as A.

Expected: A

The Hello World walks the nose of value up and down from letter to letter. A second Pinocchio, direction, lies or tells the truth to say which way, so value can make the right claim. The program prints HelloWorld without a space and ends on 12, which the specification calls a line feed. 12 is the octal code of a line feed; as a byte it is a form feed, and that is what it prints.

Patterns it teaches

  • Hostile design: a variable changes by 1 only through a claim about it, and the only loop restarts a whole Pinocchio.

Further

Also in Jokes

Write your own in Run Convert a program from Pinocchio

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: pinocchio.

Command line

shib run pinocchio -e 'Pinocchio main {
	liar.talk();
	if (liar.nose != 65) {
		Geppetto.talk();
	}

	if (liar.nose == 65) {
 		truthseeker.talk();
	}
}

Pinocchio liar {
	yes(liar.nose == 65); #If it is 65 before liar is run, it will decrease. In other words, failsafe.
}

Pinocchio truthseeker {
	print(liar);
}'
shib manual pinocchio

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/pinocchio.js

Docs: Kernel instructions · The .shib format · Command line · Adding a language

Source esolangs.org (CC0) · Edit on esolangs.org