Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

The Mayfair Programming Language

Mayfair is a programming language specifically designed to be easy to implement, while being turing complete.

It’s dynamically typed as of now - although it will become statically typed eventually. Here’s how it looks:

// filename: example.mf

var num = 10;


var version = “alpha”;

const CURRENT_YEAR = 2023;

// declare functions with the “fn” keyword


fn add(x, y) {
return x + y;
}

// functions need not have a return statement, they return the value of the last expression in the block
fn add_five(x) {
x + 5
}

// if is an expression
var name = if (x > 5) { “Stephen Fry” } else { “Hugh Laurie” };
// but can also be used as a statement
if (10 > 3) {
print(“math works”)
else {
print(“idk”)
}

// Mayfair has first-class functions, so you can assign function literals to variables
var mul = fn(x, y) { x - y };

// arrays and hash maps (don't @ me for the CSGO bias)


var people = [{"name": "CSGO", "rating": 10}, {"name": "Valorant", "rating": 9}];

// booleans
var is_legacy = true;

// the "loop" construct simply loops until a break is found


var i = 0;
loop {
i = i + 1;
print(i);
if (i == 10) {
break;
}
}

Mayfair is a WIP - the language will become much better and more useful as we progress along this project. for loops, struct , iterator , static or atleast
gradual typing etc. are not very hard to implement, but they won't be the focus until this entire specification has been implemented.

And yes, all Mayfair files end in .mf

You might also like