From Esolang
Jump to navigation Jump to search


  1. "The variable names can be anything including special names." Does this mean you can redefine any reserved word or numeric literal, and put symbols, spaces, newlines, control characters, whatever you want in a variable name?
  2. Where is the line drawn between plus meaning arithmetic addition and plus meaning string concatenation? (What exactly defines what's a number and what's a string?)
  3. Going by the 99 bottles of beer example, it would appear that variables in rvalues are sometimes by value and sometimes by reference. What exactly is the rule on this?
  4. Can a variable and a loop have the same name?
  5. What is an if loop, anyway?

-- Smjg 11:50, 22 August 2009 (UTC)


  1. The variable names should be limited to the printable ASCII characters (32-126) for the sake of clarity and ease, but you could potentially use control characters if you so choose.
  2. If both of the values are numerals, then the plus is used for arithmetic, but if one or the other value is not entirely numeral the plus acts by string concatenation.
  3. You can use either. If the value referenced is a variable name, then the variable's value is used, otherwise the value given is used. This means that using numbers as variable names is probably not a smart idea.
  4. Yes, but naming them seperately is preferable for clarity reasons.
  5. An if loop executes once if the condition is true, while a while loop executes as long as the condition is true when the loop ends. Technically an if loop is not actually a loop because it does not loop, but is similar to the if... then... statement in many other non-esoteric languages. This is probably what was confusing you.

Hopefully I've successfully answered your questions. PuzzleHunter84 22:11, 22 August 2009 (UTC)

I see ... but still:

  1. Allowing control characters would seem to lead to ambiguity. OK, so maybe it's unambiguous as long as = cannot be in a variable name.
  2. I thought so ... but for this to be meaningful, we need a complete spec of number syntax. Are negative numbers allowed? Decimals? What about scientific notation? And does whitespace around the number change things?
  3. Let me clarify. Given
b= bottles of beer on the wall.  
c=a plus b
d=a minus 42
how is one to know whether b is now "99 bottles of beer on the wall" or "98 bottles of beer on the wall", and whether d is now 57 or 56? If followed by
a=d plus 3
then will this expand to
a=a minus 42 plus 3
a=d plus 3 minus 42 plus 3
and so on indefinitely, or will some unspecified rule trigger a value assignment to happen instead? -- Smjg 20:26, 28 August 2009 (UTC)

More Answers

  1. = cannot be used in variable names or values, correct.
  2. For clarification on number syntax: only signed integers (- indicating negative numbers) should be used and divided by is used for integer division. Any non-numeral character other than - (even whitespace) would cause the value to become a string. For example
c=a plus b
would result in c being 10, but
c=a plus b
would result in c being the string "55 " without the quotes.
  1. When a variable is given a new value, that value is used in place of the old value in math, string concatenation, etc. to decide other values. In your example
b= bottles of beer on the wall.  
c=a plus b
d=a minus 42
a=d plus 3
At line 1, a is set to 99. At line 2, b is set to the string " bottles of beer on the wall. " without the quotes. At line 3, c is set to a plus b, which is currently the string "99 bottles of beer on the wall. " without the quotes. At line 4, d is set to a minus 42, which is currently 57. At line 5, a is set to the new value of 98; this changes the value of c to the string "98 bottles of beer on the wall. " without the quotes and the value of d to 56. At line 6, a is set to the new value of d plus 3 which is currently 59. In another case where you have something like this
a=a plus 5
In this case, a would be set to 10. Then a would be set to the new value that is a plus 5. For this the old value of a is used to determine the new value, which would be 15. A variable is only set once for each time it appears as the variable name (except in the case of specials such as print, input, and loops).

Hope this helped with clarification.

Damn it all. That last 1 should be a 3. --PuzzleHunter84 00:29, 30 August 2009 (UTC)

So variables c and d hold the expressions a plus b and a minus 42 respectively. When a is assigned d plus 3, it expands to a minus 42 plus 3, but since this means a is now defined in terms of itself, the a in that expression is replaced with its existing value. Have I got the right idea?
Moreover, if I did something like
a=a plus d
then what would happen? Does a now equal 111, 147 or what? -- Smjg 01:18, 30 August 2009 (UTC)

Yes, you have the right idea. In the last example, a would now equal a plus d, which would be 42 plus 105 or 147. Once the value of d is changed from 69 to 105, a changes its value to act as if d had always held a value of 105... if that makes any sense at all. I doubt anything like that will pop up in practical programs but you never know. -- PuzzleHunter84 01:30, 30 August 2009 (UTC)

The construct above is similar to all variables acting as more of a pointer/reference than an actual "variable" but still... PuzzleHunter84

So once line 3 has been executed, the expression stored as a is 42 plus d. -- Smjg 18:04, 12 September 2010 (UTC)
Essentially PuzzleHunter84

This is Turing-complete?

I proved it to be Turing-complete. Is the proof right? --User:A 11:21 17 Jul. 2018

Yes, your proof was basically correct. (The only thing missing was handling of "unbalanced" loops which contain a different number of < and >, but the Collatz construction doesn't use those, so all that was needed was to point that fact out.) I reformatted the proof to be a bit easier to read, while keeping the content the same. --ais523 18:08, 17 July 2018 (UTC)