syntax: 'var'->'let' 'function'->'func'

- 'var' has some weird scoping connotations with users of JS. better to change it to 'let', which will decide whether to make the variable a local or a global
- 'func' looks visually appealing lol
- some minor refactoring done in cparse.c
This commit is contained in:
2023-02-09 15:58:25 -06:00
committed by cpunch
parent e335fd95d6
commit 8ac8085d20
16 changed files with 95 additions and 99 deletions

View File

@@ -1,22 +1,22 @@
proto Vector
function __init(self)
func __init(self)
self.vector = []
self.x = 0
end
function push(self, val)
func push(self, val)
self.vector[self.x++] = val
end
function pop(self)
func pop(self)
return self.vector[--self.x]
end
function __index(self, key)
func __index(self, key)
return self.vector[key]
end
function __iter(self)
func __iter(self)
// you don't *have* to make a new object, i just wanted to show off anonymous functions
return {__next = (function(self)
return self.vector[self.iterIndex++]
@@ -27,9 +27,9 @@ proto Vector
end
end
var vector = Vector()
let vector = Vector()
for (var i = 0; i < 100000; i++) do
for (let i = 0; i < 100000; i++) do
vector:push(i)
end