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, Actions & Namespaces

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. The same convention applies to actions, which have a trailing exclamation mark though.

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
numerator(Rat) = mul($a den($a));
numerator(-0.75); # -3

Namespaces are also written in snake_case with a preference for single-word names.

# Example
collection<
  to_tuple(Set) = [peel($a)];
  to_set(Tuple) = {peel($a)};
>;
collection.to_set([9, 1, 1]); # {1, 9}

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 & Languages

The names of constants and Languages 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!";
SPEED_OF_LIGHT = 299792458; # in meters per second
GOLDEN_RATIO = PHI;
DIGITS ~ U+0030..U+0039 | U+0030..U+0039 DIGITS;

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;