IRC

From Esolang
Jump to navigation Jump to search
This page is about the programming language. See Esolang:Community portal #IRC for the IRC community about esoteric programming.

IRC is a Turing complete programming language created by Smallhacker.

Description

IRC shares the format of IRC conversations on mIRC. It involves unvoiced (comments), voiced (variables) and ops (commands) talking to each other in one or more channels (threads).

Each program is divided into several files, one main file and then one for each channel.

Main file

The main file contains the name of the program, the name of the channels and the default error message, in that order. The format is as follows:

/nick [name]
/join [first_channel]
/join [second_channel]
...etc...
/join [last_channel]
/quit [error_message]
  • [name] is the name of the program. The name follows the same restrictions as names on IRC. Must not be one of the reserved words.
  • [nth_channel] is the name of the nth channel in the program. The channel name follows the same restrictions as channel names on IRC (and must therefore be prefixed by #). The channel's code is stored in "[nth_channel].irc"
  • [error_message] is the error message shown if an error occurs (such as division by zero). This may be left empty.

Channels

A channel is where the chatting takes place. One can have multiple channels in the same program, allowing simple multi-threading. All channels are created when the program starts, meaning that creating channels during run-time isn't possible.

All channels must start with the following line:

* [name] has joined [channel_name]

Where [name] is the program name and [channel_name] is the name of the channel (same as file name).

To leave a channel (kill the thread), the following code is used:

* [name] has left [channel_name]

The program runs until all channels has been left or the following code is used:

* [name] has quit IRC (Quit: [error_message])

[error_message] is the error message that will be shown once the program has ended. (This may be left empty, causing no error message to appear)

Voiced

The voiced are the variables (signed integers) of IRC. They give themselves values and perform operations by talking.

Before a voiced can be used, it must enter the channel. This is done by the following line:

* [voiced] has joined [channel_name]

Where [voiced] is the name of the voiced (must not be the same as the program name or any reserved word), and [channel_name] is the name of the current channel. In the same way, a voiced may also leave the channel:

* [voiced] has left [channel_name]

Now, to actually make them voiced, you must voice them:

* [name] sets mode: +v [voiced]

Where [name] is the name of the program.

A voiced can be in multiple channels at once. (The voiced are global, meaning that they have the same value in all channels.)

Here's the things a voiced can do:

<[voiced]> I'm [value]. ([voiced] = [value])
<[voiced]> I'm not [value]. ([voiced] = ![value], bitwise NOT)
<[voiced]> I'm [value] [operation] [value]. ([voiced] = [value] [operation] [value])

Where [voiced] is the name of the voiced being modified and [value] is a voiced or a number. The word "myself" may be used as one or more of the values to make it refer to itself.

Valid operations are:

  • plus
  • minus
  • times
  • divided by
  • to the power of
  • and
  • or
  • xor

("and", "or" and "xor" are bitwise)

Topics

Topics are the counterpart to labels. A topic is created with the following line:

* [name] changes topic to '[topic]'

Where [name] is the name of the program and [topic] is the name of the topic. Topics are not global, meaning that the same topic name may be used in more than one channel.

Ops

The ops are the ones that gets stuff done. There are four ops: Jump, If, Output and Input.

Jump

Changes to another topic (jumps to a label) or goes off topic (jumps to a subroutine).

<jump> Let's talk about [topic]. (Jumps to label [topic])
<jump> Off topic: Let's talk about [topic]. (Jumps to subroutine [topic])
<jump> They're talking about [topic] in [channel]. (Causes thread [channel] to jump to subroutine [topic].)
<jump> Let's get back on topic. (Returns from subroutine)

If

Compares voices with other voices or numbers. If the condition is false, it skips the next line.

<if> [voiced], are you [condition]?

Valid conditions are:

  • equal to [value]
  • not equal to [value]
  • greater than [value]
  • less than [value]
  • equal to or greater than [value]
  • equal to or less than [value]

Where [value] is a voiced or a number.

Output

Prints numbers or characters to the screen.

<output> What's your value, [voiced]? (Outputs the value of the voiced)
<output> What's your character, [voiced]? (Outputs the ASCII character of the voiced)

Input

Input reads from the keyboard.

<input> Hey, [voiced]. (Sets [voiced] to currently pressed key)

Unvoiced

Unvoiced are the counterparts to comments. They are created in the same way as voiced, except that the "* [name] sets mode: +v [voiced]" line is not used on them. The unvoiced's messages are ignored:

<[unvoiced]> This line will be ignored.

Reserved words

These words may not be used as the name of the program, voided or unvoiced:

  • jump
  • if
  • output
  • input
  • myself
  • not
  • or

To do

There's still some things left to be added to the language. Suggestions and comments are welcome in the Talk page.

  • Arrays
  • ...more?

Examples

Note: These has not been tested, as there's no interpreter.

Hello World

(helloworld.irc)

/nick helloworld
/join #world
/quit "Something went wrong."

(world.irc)

* helloworld has joined #world
* temp has joined #world
* l has joined #world
* o has joined #world
* helloworld sets mode: +v temp
* helloworld sets mode: +v l
* helloworld sets mode: +v o
<l> I'm 108.
<o> I'm 111.
<temp> I'm 72.
<output> What's your character, temp?
<temp> I'm 101.
<output> What's your character, temp?
<output> What's your character, l?
<output> What's your character, l?
<output> What's your character, o?
<temp> I'm 32.
<output> What's your character, temp?
<temp> I'm 87.
<output> What's your character, temp?
<output> What's your character, o?
<temp> I'm 114.
<output> What's your character, temp?
<output> What's your character, l?
<temp> I'm 100.
<output> What's your character, temp?
* helloworld has quit IRC (Quit: )

External resources