SE

From Esolang
Jump to navigation Jump to search

SE is short for "self-explanatory", which is exactly what this language stands for. I've included the syntax for the really dumb people who can't make up how to use it.


Note: Maybe it's not so esoteric :| Might make an interpreter (other than SE's one) soon :)

Syntax

Variables

To assign a value to a variable, you use

<type> _<variablename> is <value> end

Examples

character _c is x end
number _x is 42 end

Exceptions

It's forbidden to use the following names:

  • _arguments This one is reserved for use in functions (See Functions)
  • _system This one is reserved for getting information from the system (See _system)
  • _space This is used as a space in character arrays (See Arrays)
  • _enter This is used as a newline in character arrays (See Arrays)
  • _underscore This is a normal underscore without referencing to variables

Arrays

Arrays are created just as easy

array _<variablename> is [_foo _bar _baz] end

The SE interpreter decides the type of the array by the type of the first item.

Examples

array _foo is [f o o] end

Linked array

There is a special type of array, called linked array, which works like a hashmap. The type is linkarray It has the same syntax as a normal array, but where you can use

do > with [f o o] from _<link array name> 

which outputs "bar" (See Examples below) (See Input and output)

Examples

array _foo is [f o o] end
array _bar is [b a r] end
array _baz is [b a z] end
array _too is [t h a t _space o t h e r _space o n e] end
linkarray _persons is [_foo_bar _baz_too] end

Notice that you have to use variables, as they have to be linked by having no space between the names.

Input and output

Inputting is done per character with the special character <

character _input is < end

Outputting is done with the special character >

do > with _output end

Reading from a file is done with << from <filename>

array _file is << from [f o o . t x t] end

Writing to a file is done with >> to <filename>

do >> to [b a r . t x t] with _output end

Examples

See Hello world on the bottom of the page

Functions

A function is a valid type, so a function is constructed as follows

function _foo is { do > with _argument:1 end } end

It can be stretched too

function _bar is {
 do > with _argument:1 end
} end

To call a function, you should use do:

do _foo with [h]

To return a value, use send

function _echo is { send _arguments end } end

System functions

  • + [array] Add all numbers from array. If the type of array is not number, throw an error called brick through Windows (Be happy when you're using a Linux/UNIX based OS)
  • - [array] Same as +, but subtracting this time
  • * [array] Same as -, but multiplying
  • / [array] Do I have to explain?
  • > Outputting (See Input and output)
  • < Inputting (See Input and output)
  • >> ...
  • <<

Examples

function _foo is {
 number _added is { do + with [_argument:1 _argument:2] end } end
 send
} end
do > with { do _foo with [1 2] end } end

Outputs

3
do > with { do _foo with [1 2 3] end } end

Outputs

3

We only used argument 1 and 2 in function foo, watch closely ;)

_system

The variable _system is a special variable, as it is a linked array (See Linked array) It contains the following information:

  • name [Type: array of character] This is the name used by the current user
  • arch [Type: array of character] This is the architecture from the CPU (32 or 64)
  • file [Type: array of character] This is the name from the current opened file
  • inter [Type: short-cut for array of character] This is a short-cut for interpreter (See below)
  • interpreter [Type: array of character] This creates the SE interpreter
  • secret [Type: function] This is a function for the curious ones

Examples

do _system:secret end

Simple programs and examples

Hello World

A simple Hello world program

array _hello is [H e l l o] end
array _world is [W o r l d] end
array _hw is [_hello _space _world !] end
do > with _hw end

Quine


Yes, a file containing nothing will output nothing :3

do > with { do << from _system:file end } end

By reading it's own file

Interpreter

The only interpreter is created in SE itself, and can only be run in SE.

array _int is _system:interpreter end
array _filename is [s e _underscore i n t e r p r e t e r . s e] end
do >> _filename with _int end

To run the interpreter with a file after creating it using the above steps

$ se_interpreter.se <name>

To run the Hello World! example from above:

$ se_interpreter.se helloworld.se

Make sure the se_interpreter.se file is in your path and runnable!