Live data from Hacker News

Show HN: Chicken chicken chicken – chicken chicken programming language

torso.me

71–74 of 74 posts

Re: Show HN: Chicken chicken chicken – chicken chicken programming language

#71
post #36

Chicken! Chicken chicken? //Chicken chicken chicken chicken (chicken = 0; chicken++; chicken = chicken/0){ chicken; }

chicken = 0 and chicken = chicken/0 are both declarative which will break your chicken loop. Also, anything divided by 0 is undefined. Try:

chicken(chicken = 0; chicken

  chicken chicken;
}

Which in pure chicken chicken would be:

chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken

chicken chicken chicken

chicken

[Edit: Add chicken chicken interpretation]

Re: Show HN: Chicken chicken chicken – chicken chicken programming language

#72

If Torbjörn Söderstedt would like to explain how chicken.js works - there is now an open stackoverflow question: http://stackoverflow.com/questions/17414435/how-does-chicken...

There are four statements: 1. Initialization 2. Read next character or bytecode 3. Conditional, first leg is parsing and second intepretation. 4. Return

When parsing, the function will call itself recursively as chicken(linenumber, 0). When interpreting, it calls itself as chicken(undefined, undefined). With the second parameter 0 or undefined, the initialization code will not run again. With the first parameter undefined, it will run the interpreter instead of the parser. (It is important that the line number is non-zero.)

This is where the implementation gets a bit ugly. There's no way of preventing the interpreter from running. That means the error message must form valid bytecode. It does this by setting the stack pointer to -1 and returning an array of length two. The interpretation starts at index 2, which will be read as undefined and thus interpreted as the axe instruction (halting the program). sp will have been increased to 0 by the initialization and thus points to the error message at index 0 in the array, which will be returned as the result. (The second value in the array is unused, and was only inserted to avoid using a parenthesis.)

That should hopefully clear up the big picture. Some small notes:

Comparing input and code during initialization should always be false. When negated, it produces the value 0.

The value after && that follows the comparison with "n" is always true. It was just a way to avoid a parenthesis.

CHICKEN ++- CHICKEN produces -1. The side effect isn't used.

Post reply on HN