We are currently working on new rules for what content should and shouldn't be allowed on this website, and are looking for feedback! See Esolang:2026 topicality proposal to view and give feedback on the current draft.

Typeid

From Esolang
Jump to navigation Jump to search

Typeid is an esolang invented by User:None1, inspired by Brain-Flak and brainf*ck (not brainfuck). It uses Itanium ABI mangled types as programs.

Memory

It has a stack with unbounded integers. Popping from an empty stack results in 0.

Commands

Built-in Types

Command Meaning in Typeid Meaning in Itanium ABI
a Input a character and return it signed char
b Input an integer and return it bool
c Pop stack and print as ASCII, returns 0 char
d Pop stack and print as integer, returns 0 double
e The same as c, but returns the value popped long double
f The same as d, but returns the value popped float
g Returns 0 __float128
h Returns 1 unsigned char
i Pop a and b, return b+a int
j Pop a and b, return b-a unsigned int
l Pop a and b, return b*a long
m Pop a and b, return floor(b/a) unsigned long
n Pop a and b, return b%a __int128
o Pop a and b, return ba unsigned __int128
s Swap top stack values, return 0 short
t Perform a left circular shift on the three top stack values (a b c)->(b c a) unsigned short
v Pop a and b, return a bitwise AND b void
w Pop a and b, return a bitwise OR b wchar_t
x Pop a and b, return a XOR b long long
y Pop a, return ~a unsigned long long
z Pop a, return -a ...
Sa Return a random integer within [0,1] std::allocator
Sb Pop x, Return a random integer within [1,x] std::basic_string
Sd Return the current UNIX timestamp as an integer std::iostream
Si Return the length of the stack std::istream
So Pop x, return sign(x) std::ostream
Ss Pop a C-style string (Pop all the numbers until top is zero) from the stack and print it, returns 0 std::string

A pointer type (Ptype) to a type pushes the return value of that type onto the stack and returns it.

A const type (Ktype) to a type prints the return value of it as an ASCII character and returns it.

A reference type (Rtype) to a type prints the return value of it as an integer and returns it.

Custom types

Namespace names/Types without template arguments

Their names are simply printed when they're executed. 0 is returned.

Types with template arguments

Their exact names don't matter. Instead, the lengths of them do.

The syntax is like this (spaces are just for clarity):

length name I arguments E
Length Meaning
1 Return the sum of all arguments
2 Return the product of all argments
3 While top of stack is nonzero, execute the arguments as code. Return the sum of all runs
4 While top of stack is zero, execute the arguments as code. Return the sum of all runs
5 While stack is nonempty, execute the arguments as code. Return the sum of all runs
6 While stack is empty, execute the arguments as code. Return the sum of all runs
7 If top of stack is nonzero, execute the arguments as code. Return the sum of all arguments
8 If top of stack is zero, execute the arguments as code. Return the sum of all arguments
9 If stack is nonempty, execute the arguments as code. Return the sum of all arguments
10 If stack is empty, execute the arguments as code. Return the sum of all arguments
11 Execute the arguments as code forever
12 and above Execute the arguments as code. Return length-12

Examples

Cat

11elevencharsIKaE

Demangled:

elevenchars<signed char const>

Hello, world!

N5Hello1_IK2aaI1aIhhhhE1bIhhhhhhhhhhhEEK2bbI1cIhhhhE1dIhhhhhhhhEE5worldK2ccI1eIhhhE1fIhhhhhhhhhhhEEEE

Demangled:

Hello::_<aa<a<unsigned char, unsigned char, unsigned char, unsigned char>, b<unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char>> const, bb<c<unsigned char, unsigned char, unsigned char, unsigned char>, d<unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char>> const, world, cc<e<unsigned char, unsigned char, unsigned char>, f<unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char>> const>

A+B

R1_IbbE

Demangled:

_<bool, bool>&

Truth Machine

1_IPbPf3aaaIPfEE

Demangled:

_<bool*, float*, aaa<float*> >

Computational class

Turing complete, because it can be translated from 3-cell brainfuck:

3-cell brainfuck to Typeid translation
3-cell brainfuck Typeid
begin
1aIPgPgPg
>
tt
<
t
+
hPi
-
hPj
[
3aaaI
]
E
end
E

Implementations

It's unimplemented for now. The author plans to add an implementation in Python using the itanium_demangler package.