From a6dc46149c8f97ec4499de8593cca04d09b03ab8 Mon Sep 17 00:00:00 2001 From: Jacob Signorovitch Date: Thu, 7 Nov 2024 19:55:54 -0500 Subject: [PATCH] README.md --- README.md | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0570452..827a5d4 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,38 @@ # SCL: Simple Calculator Language -A spiritual successor to halk. +## Syntax + +As one would expect, you can evaluate simple infix expressions: + +```scl +> 1 + 1 += 2 +``` + +You can also define your own functions: + +```scl +> f(x) 2x +> f(2) += 4 +``` + +SCL will dynamically decide on types, but you can state them explicitly as +well: + +```scl +> f(x:int) 2x +> f(2.2) +! f(x:int): x must be of type int. +``` + +Variables can be defined, with several attributes: + +```scl +> a = 1 // Interpret type automatically. +> b:int = 1 // Must be int. +> c:const:int = 1 // Constant: value can never change. +> d:lazy = (1 + 1) // Interpreter will wait as long as possible before + // evaluating. +``` +