From Esolang
Jump to navigation Jump to search

Haddock is a odd programming language, based on the famous concept of the Deadfish programming language. The only major differences are:

  • Expansion of the negative limit from -1 to -2.
  • Expansion of the maximum limit from 256 to 1024(from 2^8 to 2^10).
  • Addition of cube command.
  • Addition of eplus function, which squares the cells value, adds 2 and doubles it. (Of course the full value will not be displayed!

The "Haddock Standard Organization" published a standard for all Haddock interpreters:

  1. All the compilers/interpreters for Haddock must have the set of instructions portrayed above,plus the standard Deadfish ones.
  2. All the compilers/interpreters for Haddock must have the word Haddock somewhere in their name. (E.g CaptainHaddock&Tintin, AtlanticHaddock, PythoneatsHaddock)
  3. All the compilers/interpreters shall not have file I/O. All code will be written in the REPL
  4. All the compilers/interpreters shall have a REPL.

Also, the HSO reminds you that rules are made to broken!(except of rule 1)

Implementing Haddock

Several attempts have been a made by HSO to make a Haddock interpreter. Here is AtlanticHaddock v 0.1: (Thanks to Jonathan Tod Skinner for creating the original Python Deadfish interpreter!)

# Based on Jonathan Tod Skinners Python Deadfish interpreter.
# Changed by Singingbanana & Dan_zh.
# This code is hereby in public domain.
# Initialization
accumulator = 0

# Main program loop
while True:
    # Get user input
    cmd = raw_input('>> ')
    if accumulator == 1024 or accumulator == -2:
        # Overflow, reset accumulator
        accumulator = 0
    # Process input
    if cmd == 'i':
        accumulator += 1 # Increment
    elif cmd == 'c':
        accumulator * accumulator * accumulator
    elif cmd == 'e':
    elif cmd == 'd':
        accumulator += -1 # Decrement
    elif cmd == 'o':
        print accumulator # Output
    elif cmd == 's':
        accumulator *= accumulator # Square
        print 'Unrecognized command.'