mirror of
https://github.com/CPunch/Cosmo.git
synced 2026-02-03 17:40:02 +00:00
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:
@@ -17,16 +17,16 @@ assert(2 / 5 + 3 / 5 == 1, "PEMDAS check #2 failed!")
|
||||
// iterator test
|
||||
|
||||
proto Range
|
||||
function __init(self, x)
|
||||
func __init(self, x)
|
||||
self.max = x
|
||||
end
|
||||
|
||||
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
|
||||
@@ -35,7 +35,7 @@ proto Range
|
||||
end
|
||||
end
|
||||
|
||||
var total = 0
|
||||
let total = 0
|
||||
for i in Range(100) do
|
||||
total = total + i
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user