ALEFL

From Esolang
Jump to navigation Jump to search

ALEFL (Alpha-Less Exception&Function Language) is an esolang invented by User:None1. Just like its name, it uses no letters and control flow is done by exception and functions.

Features

Type system

There are only 2 types in ALEFL: integers and functions.

Function definition

To define a function, use:

$function_name(arg1,arg2,...){CODE}

Note that function names and argument names must not contain letters. In addition, they must not start with digits.

Sentence separator

Like C and C++, the sentence separator in ALEFL is ;.

Raising an exception

To raise an exception (any integer or function), use:

!expression;

An uncaught exception prints no error message.

Catching an exception

To catch an exception, use:

@{CODE}#(expression or ...){CODE}[#(expression or ...){CODE2}...]

It tries executing CODE'. If an exception is raised, it goes through every # clause in the statement. If the exception equals to the expression in a # clause, the corresponding code is executed and # clauses in this statements after this won't be executed. ... can match any exception.

Arithmetic and comparison

ALEFL uses bignums. It supports these operators: +,-(unary minus and binary minus),*,/,//,%,**,&,|,^,~,>,<,==,!=,>=,<=,+=,-=,*=,/=,//=,&=,|=,^=,%&#61,**&#61,&&,||,!.

Integers are callable

Every function has an ID (1-indexed, ordered by definition). Calling an integer is equivalent to calling the function with ID equal to the integer (If there's no such function, it does nothing).

Variables

Variables don't need declaration before assignment. Only integers can be stored in variables. ? is a special variable, before a # clause is executed, it stores the caught exception. If the exception is a function, it stores its ID.

Note that variable names must not contain letters.

I/O

I/O is done by a function called ,, whose ID is 0. When calling with no arguments, it reads a character and returns its Unicode (0 on EOF). When calling with an integer, it prints the integer as Unicode.

Examples

Hello, world!

,(72);
,(101);
,(108);
,(108);
,(111);
,(44);
,(32);
,(119);
,(111);
,(114);
,(108);
,(100);
,(33);

Cat (never terminates)

$_(){,(,());_();}_();

Cat (terminates on EOF)

===Cat (never terminates)===
$_(){'=,();,(');(!'+1)();}
$[(){!1;}
_();

See also