SendStuff

From Esolang
Jump to: navigation, search

The SendStuff esoteric programming language, created by User:Zzo38, involves creating nodes to send the result(s) of the command (which can be only non-negative integers) to other nodes. There is no variables, strings, or anything else like that, only nodes and send number to another nodes.

I don't know if it is turing complete, but you can put comments on the talk page if you have questions or suggestions. If you are sure you have perfect proofs either way, you can post directly on here. If it isn't turing complete then maybe I can make a extended version of SendStuff for turing-complete.


Language Overview

The syntax of a node is:

  • First a character to define the type, a vertical bar if it is neither the input nor output of the parent node, greater than sign if the parent node sends to this node, or less than sign if this node sends to the parent node.
  • Next optionally can be the name of the node, which must be unique for the whole program and can contain uppercase, lowercase, numbers, underscore, and periods, and it is case sensitive.
  • And then a left parenthesis for starting it.
  • And then the command (see the command list).
  • And then the parameter for the command, which is a non-negative integer. If parameter is not given it is assumed to be 0.
  • And then the child nodes are next.
  • At the end is right parentheses.

It is also possible to send to (and receive from) nodes already defined by just the type and name, without parentheses. You don't need both send and receive indicated on every node, just one of them is OK. If you put both, it will do twice, but it can also do twice by just repeating the name twice. It will send in the order that it is given. If less than sign are used, those will be sent to this node before other send with greater than sign on the sending node.

The syntax of a macro definition is:

  • First is a at sign, followed by the name of the macro.
  • Next a left parentheses for starting it.
  • Next is all of the nodes defined in the macro (anonymous nodes are still allowed). A macro definition cannot contain another macro definition.
  • At the end is right parentheses.

To invoke a macro (and create all of the nodes it includes) is:

  • A exclamation mark
  • Name of macro
  • And parameter. That's it.

Inside of a macro definition you can include $ for a unique identifier and % for the parameter of a macro. Names without $ can be included in a macro, but if you do, its parameters and child nodes cannot have $ or % in it. Remember that even the macro name and parameter for invoking is possible to have $ or % in it, if it is in the part of the definition for another macro. (And the parameter does not have to be a number, it can be anything. If the parameter has multiple words/parts, put a colon at the beginning and a semicolon at the end.)

Comments are indicated by # and last until end of a line.

At the root you do not write the name or the command, but it will send 0 at start of program to indicate it has started. (The root node must have a greater-than sign as the type, other nodes at the root can have a vertical-bar, and are not the root node but instead are just other nodes used by the program)

Sometimes a command can send no result, one result, or possibly many results in a order. Multi results will be sent after the nodes it sends to are finish, it will try the next one. If the node is already sending some results and it is called again recursively, then it will send the new results and afterward all of that is also finish, then when the other previous calls of the node are finish it will continue the old one again if any are remaining.

Also, any closing parentheses at the end of the program can be omitted if you want to.


Commands

The commands are:

  • Input: When it receives anything, it input a ASCII (or Unicode) character and sends the input character. Send nothing for EOF.
  • Output: It output a ASCII character the number it receives, and it send nothing.
  • InputNumber: When it receives anything it will input a number and send the result.
  • OutputNumber: The received number will be written to output (as a number), and it send nothing.
  • Constant: Whenever it receives anything it will send its parameter.
  • Add: Add its parameter to received number and send the result.
  • Subtract: Subtract its parameter to received number and send the result. If result is negative, it send nothing.
  • Multiply: Multiply its parameter by received number and send the result.
  • Divide: Divide its parameter by received number and send the result, rounding down always. If divide by zero, it send nothing.
  • DivideBy: Divide received number by parameter and send the result, rounding down always. If divide by zero, it send nothing.
  • Modulo: Modulo its parameter by received number and send the result. If modulo by zero, it send nothing.
  • ModuloBy: Modulo received number by parameter and send the result. If modulo by zero, it send nothing.
  • CountUp: Send all numbers 0 up to received number (includes both).
  • CountDown: Send all numbers received number down to 0 (includes both).
  • Interleave: Interleave parameter with received number, send result.
  • LeftHalf: Does left-half uninterleave of received number.
  • RightHalf: Does right-half uninterleave of received number.


Examples

Hello, World!

>(Add      72 >(Output) 
>(Add      29 >(Output)
>(Add      7  >(Output) 
              >(Output)
>(Add      3  >(Output)
>(Subtract 67 >(Output)
>(Subtract 12 >(Output) 
>(Add      55 >(Output)
>(Add      24 >(Output)
>(Add      3  >(Output)
>(Subtract 6  >(Output)
>(Subtract 8  >(Output)
>(Subtract 67 >(Output)

Cat

>start(Input >(Output) >start)


Extended SendStuff

This is a extended version, with a few more commands and other stuff. Hopefully I can make this one turing-complete.

The command names with a slash at the end, the parameter are a name of a node, and do not have to be separated by spaces. Example:

>start(Cut/start)

Also, you can make an infinite number of nodes, after a name of a node you put the commands and children and stuff inside of {} and the primary node is that one given (numbered zero). The name of nodes, is, that name itself is same as putting comma and zero afterward, otherwise you can also put comma and a number for that given node in the set of infinite nodes, wherever the reference of a node name is used. Use the following symbols:

  • ? refers to the number of current node (can also be used in place of a comma in a name of nodes).
  • + refers to the number of the current node plus one (can also be used in place of a comma in a name of nodes).
  • - refers to the number of the current node minus one (can also be used in place of a comma in a name of nodes). If this is the number zero node, the minus sign in a parameter makes a node not exist, and in a reference node name, this reference is removed.
  • * refers to all nodes in this set (can be used in place of a comma in a name of nodes).

There are also fragments, which are another data type, and some commands accept it as parameters. Indicate fragments by square-brackets around it. You can nest fragments, and fragments can also contain unmatched parentheses too. Fragments must be concatenated to make a program. When you run this fragment program, it creates those nodes only for that program, and a ampersand represents the ending of the sub-program and the nodes for sending the result. Macros from the main program can be used in the sub-program.

New commands are:

  • Minus: As the Subtract command with parameter and received values reversed.
  • Cut/: Stops any currently pending messages from the node given as the parameter.
  • Copy/: Send a copy of any currently pending messages from the node given as the parameter.
  • Count/: Count the number of currently pending message from the node given as the parameter, send the result of that number plus the received number.
  • Create: Give a fragment as a parameter, and starts with that fragment created and sends the fragment.
  • Open: Adds a left square bracket to the end of the received fragment, sends it.
  • Close: Adds a right square bracket to the end of the received fragment, sends it.
  • Append: Appends the parameter fragment to the received fragment and send the result fragment.
  • Execute: Execute the received fragment. Anything sent to & in the subprogram is the end of the subprogram, and send the result of that. You can send multiple results in this way, too. However it will not do the results immediately until the sub-program is completely finished, after that then it will start sending the results in the order received by &.

There is also another short syntax, by putting text in between quotation marks. It can be used where the target to send results to is put, acts like multiple nodes each one is Constant and the ASCII number of the character in the string, and after the string put a greater than sign and another node (or reference) which it will send the result of that node(s) to.


Extended SendStuff Examples

Beer

|bottle(Constant " bottles of beer">(Output))
|wall(Constant 10 " on the wall">(Output) >(Output))
|line(Constant 10 >(Output))
>(Constant 98 >(CountDown
  >(Add 1
    >(OutputNumber) >bottle >wall
    >(OutputNumber) >bottle >line
  )
  "Take 1 down and pass it around">(Output) >line
  >(Subtract 1 >(Add 1 >(OutputNumber)))
  >(Minus "No more ">(Output))
  >bottle >wall >line
))