Nestplate

From Esolang
Jump to navigation Jump to search

Nestplate (from the combination of the words nest and template) is a language invented by User:GDavid to solve the problem that C++ templates are sometimes too readable. It's inspired by (()).

Syntax

The syntax of nestplate can be described as follows:

program ::= body
struct ::= (name) (argumentdefinitions) (body)
argumentdefinitions ::= ((name))
argumentdefinitions ::= ((name) ())
argumentdefinitions ::= ((name) (argumentdefinitions))
argumentdefinitions ::= argumentdefinitions argumentdefinitions
argumentdefinitions ::=
body ::= (struct)
body ::= (using)
body ::= body body
body ::=
using ::= (name) (value)
value ::= (name) (arguments)
value ::= ((value) (name))
value ::= ((name))
arguments ::= (value)
arguments ::= arguments arguments
arguments ::=
name ::= (name)
name ::= name name
name ::=

Notes:

  • value ::= (name) (arguments) is name<arguments> in C++
  • value ::= ((value) (name)) is typename value::name in C++
  • argumentdefinitions ::= ((name)) is typename name in C++
  • argumentdefinitions ::= ((name) ()) is typename ... name in C++
  • argumentdefinitions ::= ((name) (argumentdefinitions)) is template<argumentdefinitions> typename name in C++
  • Everything else should be possible to guess from it's name, if not, feel free to ask what it means on the talk page

Example code

struct zero {
}

template<typename v>
struct box {
    using value = v;
}

is

(()()())((())(((()())))((()(((()()))))))

in nestplate