1 unstable release

0.1.0 Aug 4, 2022

#805 in Programming languages

Custom license

43KB
898 lines

Rei

A programming language that just works.

Expressions

Rei is composed of a list of organised expressions.

Function, Class, Data, Trait definitions are always unique and position independent. This means you can define a function below everything else, but it is still visible to everything above it. They also cannot be shadowed, and if you attempt to redefine a function, class, etc. you will get a duplication error.

This is different to variable definition expressions. Variables are defined with vardef keywords, let, mut, const, static similar to rust and v. But variables can be shadowed and redefined in the same scope.

Everything is an Expression

Technically, everything is an expression. An expression evaluates to a value. A "statement" is a special type of expression that evaluates to (). But in rei, we dont distinguish between "statements" and "expressions". Instead expressions that arent assigned to a variable or returned by the end of a scope are simply ditched.

In this sense, rei can be most thought of as a data-oriented, functional programming language. With options for Object Oriented programming, templates and metaprogramming. Rei is meant to give you the most amount of freedom to deal with data efficiently and write up logic fast. Write now, optimise later. Though the compiler is very "strict" in another sense like rustc, dealing with nulls and borrowing rules.

An example:

fn get_data() -> uint {
    // expression evaluates to (), since mut var definition expr
    mut x = 1

    // expression evaluates to (), since scoped if expr
    for i in 0..10 {
        // expression evaluates to (), since ident ~ operator
        x++
    }

    // expression evaluates to x (identifier)
    // IDE parse warning: ditched non-trivial expr return
    x

    // expression evaluates to x (identifier)
    x
}

Reidoc

You use hash comments at hashable locations. Like rust, beginning of a file, right before a function expr, and other "non trivial", "exported" blocks. Not including local expr that arent exported. Variable defs can have a hash comment if export.

Dependencies

~6.5MB
~99K SLoC