Crates.io | reic |
lib.rs | reic |
version | 0.1.0 |
source | src |
created_at | 2022-08-04 02:29:23.781529 |
updated_at | 2022-08-04 02:29:23.781529 |
description | A compiler that just works |
homepage | |
repository | |
max_upload_size | |
id | 638505 |
size | 117,929 |
A programming language that just works.
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.
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
}
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.