corfli
Contents

Start

Language

Project

Strings

Strings are built in. They know their own length, so there's no \0 at the end and no buffer to overflow. Text is stored as UTF-8.

Putting values in text

Anything inside { } is worked out and put into the string:

name := "noa"
hp := 70
print("{name} has {hp} hp, {100 - hp} lost")
noa has 70 hp, 30 lost

Write {{ and }} for the braces themselves:

print("{{like this}}")
{like this}

Escapes

\nnew line
\ttab
\rcarriage return
\0zero byte
\\ \" \'\ " '
\{ \}{ }
\x41a byte below 0x80
\u{05D0}any Unicode letter

A raw string, r"...", keeps everything as typed, with no escapes and no { }:

print(r"C:\games\{save}")
C:\games\{save}

A string ends on the line it starts.

Joining and comparing

greeting := "hi " + "there"
greeting += "!"
print(greeting)
print(greeting == "hi there!", greeting != "hi")
hi there!
true true

A string and a number can't be added. Put the number inside the string instead: "score: {score}".

Length

.len counts letters, not bytes:

print("shalom".len, "שלום".len)
6 4

Copies

Every string variable has its own copy of the text:

a := "copy"
b := a
a += "!"
print(a, b)
copy! copy

Turning a value into a string

n := 42
s := string(n)
print(s + "!", "{n}" == s)
42! true

Methods like split, trim, contains and upper are planned for the next version.