From 76a0290290d49d156134daba3fb9a5568a2eab78 Mon Sep 17 00:00:00 2001 From: Kayne Ruse Date: Thu, 9 Feb 2023 17:46:28 +0000 Subject: [PATCH] Removed export keyword from README.md --- README.md | 2 -- scripts/small.toy | 28 ++++++++++++++++++++++++---- source/toy_common.h | 2 +- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 07cbe6f..dca91a0 100644 --- a/README.md +++ b/README.md @@ -60,8 +60,6 @@ var tally = makeCounter(); print tally(); //1 print tally(); //2 print tally(); //3 - -export tally; //export this variable to the host program ``` # License diff --git a/scripts/small.toy b/scripts/small.toy index 9259392..fd04de0 100644 --- a/scripts/small.toy +++ b/scripts/small.toy @@ -1,6 +1,26 @@ -import compound; -var arr: [int] = [1, 2, 3]; -fn f(_, v: int): int { return v + 1; } -print arr.map(f); +import standard; //for a bunch of utility functions +print "Hello world"; //"print" is a keyword + +var msg = "foobar"; //declare a variable like this + +assert true, "This message won't be seen"; //assert is another keyword + +//------------------------- + +fn makeCounter() { //declare a function like this + var total: int = 0; //declare a variable with a type like this + + fn counter(): int { //declare a return type like this + return ++total; + } + + return counter; //closures are explicitly supported +} + +var tally = makeCounter(); + +print tally(); //1 +print tally(); //2 +print tally(); //3 diff --git a/source/toy_common.h b/source/toy_common.h index c35c87f..dad72cf 100644 --- a/source/toy_common.h +++ b/source/toy_common.h @@ -6,7 +6,7 @@ #define TOY_VERSION_MAJOR 0 #define TOY_VERSION_MINOR 8 -#define TOY_VERSION_PATCH 1 +#define TOY_VERSION_PATCH 2 #define TOY_VERSION_BUILD __DATE__ " " __TIME__ //platform-specific specifications