updated README

This commit is contained in:
CPunch 2020-11-20 15:32:12 -06:00
parent 6d45c0a676
commit 6485f90c2d
2 changed files with 48 additions and 14 deletions

View File

@ -1,7 +1,41 @@
# Cosmo # Cosmo
Cosmo is a portable scripting language loosely based off of Lua. Designed for embeddability, Cosmo will have a built-in C++ wrapper for ease of use for embedding in in C++ applications. Cosmo is a portable scripting language loosely based off of Lua. Cosmo easily allows the user to extend the language through the use of Proto objects, which describe the behavior of Objects. For example the following is a simple Vector class which describes behavior for a Vector-like object.
# Why Cosmo? ```
While C++ wrappers for Lua exist (see: SolLua), they're all maintained by outside entitties while Cosmo writes it's own first party wrapper. Additionally, Cosmo is very easily modifiable having been written in clean C99 with well documented code; this makes it a great candidate for early language hackers and researchers alike. class Vector
function __init(self)
self.vector = {}
self.x = 0
end
However Cosmo is not just a friendly developer tool, Cosmo's easy syntax and readability makes it a great scripting language for anyone to use. function __index(self, key)
return self.vector[key]
end
function push(self, val)
self.vector[self.x++] = val
end
function pop(self)
return self.vector[--self.x]
end
end
var vector = Vector()
for (var i = 0; i < 4; i++) do
vector.push(i)
end
for (var i = 0; i < 4; i++) do
print(vector.pop() .. " : " .. vector[i])
end
```
> 3 : 0
> 2 : 1
> 1 : 2
> 0 : 3
# C API
The Cosmo C API is currently undocumented, however as soon as development has reached a stable state documentation on full language features and the C API will start.

View File

@ -1,28 +1,28 @@
class Stack class Vector
function __init(self) function __init(self)
self.stack = {} self.vector = {}
self.x = 0 self.x = 0
end end
function push(self, val) function push(self, val)
self.stack[self.x++] = val self.vector[self.x++] = val
end end
function pop(self) function pop(self)
return self.stack[--self.x] return self.vector[--self.x]
end end
function __index(self, key) function __index(self, key)
return self.stack[key] return self.vector[key]
end end
end end
var stack = Stack() var vector = Vector()
for (var i = 0; i < 10000; i++) do for (var i = 0; i < 100000; i++) do
stack.push(i) vector.push(i)
end end
for (var i = 0; i < 10000; i++) do for (var i = 0; i < 100000; i++) do
print(stack.pop() .. " : " .. stack[i]) print(vector.pop() .. " : " .. vector[i])
end end