From 0a4d36f2f4c88085c909cfd9b5452fa0e672d4a8 Mon Sep 17 00:00:00 2001 From: CPunch Date: Fri, 10 Feb 2023 20:46:05 -0600 Subject: [PATCH] update Docs to reflect keyword changes --- docs/control.md | 4 ++-- docs/intro.md | 2 +- docs/objects.md | 14 +++++++------- docs/operators.md | 4 ++-- docs/types.md | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/docs/control.md b/docs/control.md index 4d206fc..bede4c9 100644 --- a/docs/control.md +++ b/docs/control.md @@ -46,8 +46,8 @@ There are two main types of for loops, the traditional c-style for loops, and th The c-style for loops starts with the `for` keyword, followed by '(' and an initializer, a conditional expression, and an iterator statement each separated by a ';', followed by ')' then the `do` keyword. The loop body is ended by the matching `end` keyword. Like so: ``` -var total = 0 -for (var i = 0; i < 10; i++) do +let total = 0 +for (let i = 0; i < 10; i++) do total = total + i end print(total) diff --git a/docs/intro.md b/docs/intro.md index 8ea40b2..9867c29 100644 --- a/docs/intro.md +++ b/docs/intro.md @@ -1,6 +1,6 @@ # Introduction -Cosmo is a lightweight embeddable scripting language written in C99. Cosmo has comparable syntax to Lua 5.1, so if you are familiar with that syntax, learning Cosmo should be trivial. Cosmo has eccentric support for object-oriented programming, procedural programming, and functional programming. To see some examples that highlight the syntax, please see the `examples/` directory. +Cosmo is a lightweight embeddable scripting language written in C99. Cosmo has comparable syntax to Lua 5.1, so if you are familiar with that syntax, learning Cosmo should be trivial. To see some examples that highlight the syntax, please see the `examples/` directory. As Cosmo is an embeddable scripting language, it is designed to be extended by the host program (from here on referenced as 'host'.) Cosmo provides extensive C API for the host to set up the Cosmo VM, modify state, add custom Proto objects, define custom globals and more. diff --git a/docs/objects.md b/docs/objects.md index b7393be..e209460 100644 --- a/docs/objects.md +++ b/docs/objects.md @@ -6,17 +6,17 @@ For example, the following is a proto description for a Range Iterator Object, m ``` proto Range - function __init(self, x) + func __init(self, x) self.max = x end // __iter expects an iterable object to be returned (an object with __next defined) - function __iter(self) + func __iter(self) self.i = 0 return self end - function __next(self) + func __next(self) if self.i >= self.max then return nil // exit iterator loop end @@ -50,7 +50,7 @@ When an object is called using the `()` operator, `__init` is called and a new O Objects hold fields, these fields can be grabbed using the '.' operator. Conversely, fields can also be set using the '.' and '=' operators. For example: ``` -var object = { +let object = { field = "Hello world" } @@ -63,17 +63,17 @@ Objects have two main ways of being declared, first was just shown in the above ``` proto Test - function __init(self) + func __init(self) // __init is required for an object to be instantiated, the 'self' passed is the // newly allocated object with it's proto already set end - function print(self) + func print(self) print(self) end end -var objTest = Test() +let objTest = Test() // the ':' operator is used to invoke a method. if the '.' operator is used instead, the // raw closure will be given meaning the 'self' parameter won't be populated diff --git a/docs/operators.md b/docs/operators.md index c94bcfd..80937b7 100644 --- a/docs/operators.md +++ b/docs/operators.md @@ -17,8 +17,8 @@ | -------- | ---------------------------- | -------------------------------------- | | `!` | "Not" logical operator, flips the logical polarity. | `print(!true)` -> `false` | | `#` | "Count" calls '__count' metamethod on objects or gives the count of entries in tables | `print(#[1,2,3])` -> `3`, `print(#{__count = function(self) return self.x end, x = 1337})` -> `1337` | -| `++` | Increment operator. | `var i = 0 print(++i .. ", " .. i++ .. ", " .. i)` -> `1, 1, 2` | -| `--` | Decrement operator. | `var i = 0 print(--i .. ", " .. i-- .. ", " .. i)` -> `-1, -1, -2` | +| `++` | Increment operator. | `let i = 0 print(++i .. ", " .. i++ .. ", " .. i)` -> `1, 1, 2` | +| `--` | Decrement operator. | `let i = 0 print(--i .. ", " .. i-- .. ", " .. i)` -> `-1, -1, -2` | | `( ... )` | Call operator. Arguments should be separated using `,`. | `print("Hello", " ", "world!")` -> `Hello world!` | > -> means 'outputs' diff --git a/docs/types.md b/docs/types.md index 1e8ca9c..5bb029a 100644 --- a/docs/types.md +++ b/docs/types.md @@ -17,5 +17,5 @@ There are two main types of datatypes in Cosmo, primitives and references. Primi | String | A string of characters | `"ABC"`, `"\x41\x42\x43"`, `"\b1000001\b1000010\b1000011"` | | Object | A stateful data structure. See `objects.md`. | `{x = 3}`, `proto Test end` | | Table | A generic data structure. | `[1,2,3]`, `[1 = "hello", "two" = "world"]` | -| Function | A callable routine. | `function() print("Hello world!") end` | +| func | A callable routine. | `function() print("Hello world!") end` | > There are some other reference datatypes that are used internally, however these will remain undocumented until they are accessible by the user \ No newline at end of file