Unnecessary is a programming language from 2005 by Keymaker where the existence of a program file is considered an error. The valid Unnecessary program file extension is 'unn'. However, if there is no program file, the interpreter or compiler can work normally and perform a nop.
The language was designed to be easy to learn and implement. It was also part of the design to make the language very simple to program in.
Storing all your Unnecessary programs takes less than a bit of space, and distributing programs is fast and easy.
An Unnecessary interpreter must check if the program file exists and then do the following:
- If the file doesn't exist, run NOP and end the program execution successfully.
- If the file exists, report an error and terminate immediately.
A compiler should make the language it compiles to perform only nop and nothing else; but naturally only if the Unnecessary program file is not found.
Run file 'example.unn' with your Unnecessary interpreter. (Note: First make sure there isn't a file called 'example.unn'. If there is, remove it before executing (or change to a different directory).)
In case you use a UNIX system and do not have an Unnecessary interpreter, UNIX systems have a similar program built in – use the command test ! -e to activate it (followed by filename). However, if the file does exist it will fail silently instead of reporting an error, so it is not perfect, but it is close enough in case you don't care about the error messages.
If you like errors, you can use this slightly more complex command: test ! -e example.unn || echo "Error: File exists" (substitute example.unn with your file).