Conventions

None of the following guidelines are enforced by Quirl. Consider to adopt them anyway. Adhering to conventions makes it easier for people to understand your code.

Functions

Function names are written in snake_case: they consist of small letters and words are separated by underscores. A function name should be made of at least two characters.

You will probably notice that the names of Quirl's core and additional functions are typically short, sometimes cryptically short. This was a deliberate choice for the limited number of built-in functions only. Please feel encouraged to use expressive names for your own functions! They make code more readable.

# Examples
successor(Int) = add($a 1);
successor(2); # 3
convert_to_float(Float) = $a;
convert_to_float(\2); # !1.4142135623730951

Deviate!?

Sometimes functions are simply used to store a bunch of constant values. It can make sense to choose an all-capitals name like for actual constants in that case.

# Example
POLYGON(3) = "triangle";
POLYGON(4) = "quadruple";
POLYGON(5) = "pentagon";

Constants

The names of constants are written in capital letters. You can use the underscore _ to separate words in a name.

# Examples
PHI = 1/2+1/2\5;
BYE = "Auf Wiedersehen!";
GOLDEN_RATIO = PHI;
SPEED_OF_LIGHT = 299792458; # in meters per second

Deviate!?

A small-letter name is fine, if your constant is callable and you intend to use it like a function.

# Examples
next = add(? 1);
next(3); # 4
square = x^2;
square(3); # 9

Types & Traits

Types and traits start with a capital letter and continue small – just like people's names in the English language.

# Examples
Collection = Set+Tuple;
Int, Rat;