aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authors-ol <s-ol@users.noreply.github.com>2020-02-10 15:12:53 +0000
committers-ol <s-ol@users.noreply.github.com>2020-02-10 15:12:53 +0000
commite6ad30365e5c191ad0cb4b98f0d543414b8be7ef (patch)
tree8d67fa54725f27953d21a0833d8dd5f51680b2d8
parentfinally implement function diffing (diff)
downloadalive-e6ad30365e5c191ad0cb4b98f0d543414b8be7ef.tar.gz
alive-e6ad30365e5c191ad0cb4b98f0d543414b8be7ef.zip
closures
-rw-r--r--core/cell.moon2
-rw-r--r--core/invoke.moon6
-rw-r--r--init.moon1
-rw-r--r--registry.moon1
-rw-r--r--test.alv18
5 files changed, 15 insertions, 13 deletions
diff --git a/core/cell.moon b/core/cell.moon
index 1a25c0a..ae6eea4 100644
--- a/core/cell.moon
+++ b/core/cell.moon
@@ -36,7 +36,7 @@ class Cell
@tag = cell.tag -- for writing back to file
clone: (prefix) =>
- tag = Const.sym prefix\getc! .. @tag\getc!
+ tag = Const.sym prefix\getc! .. '.' .. @tag\getc!
children = [child\clone prefix for child in *@children]
Cell tag, children, @white
diff --git a/core/invoke.moon b/core/invoke.moon
index 6458f2b..9955bce 100644
--- a/core/invoke.moon
+++ b/core/invoke.moon
@@ -45,9 +45,9 @@ class fn_invoke extends Action
true
- eval: (scope, tail) =>
+ eval: (outer_scope, tail) =>
assert @head.type == 'fndef', "cant fn-invoke #{@head}"
- { :params, :body } = @head\getc!
+ { :params, :body, :scope } = @head\getc!
assert #params == #tail, "argument count mismatch in #{@head}"
@@ -56,7 +56,7 @@ class fn_invoke extends Action
for i=1,#params
name = params[i]\getc!
argm = tail[i]
- fn_scope\set name, L\push argm\eval, scope, @registry
+ fn_scope\set name, L\push argm\eval, outer_scope, @registry
body = body\clone @tag
diff --git a/init.moon b/init.moon
index 5da1dd2..41acabe 100644
--- a/init.moon
+++ b/init.moon
@@ -25,7 +25,6 @@ delta = do
if last
target, current = (last + period), monotime!
if current > target
- print current, target
L\warn 'Frame Skipped!'
else
sleep target - current
diff --git a/registry.moon b/registry.moon
index 7c03e1b..a946e9a 100644
--- a/registry.moon
+++ b/registry.moon
@@ -38,6 +38,7 @@ class Registry
Const.num num
eval: (ast) =>
+ @map = {} -- in case we errored last time
scope = Scope ast, @globals
@root = ast\eval scope, @
diff --git a/test.alv b/test.alv
index 9e7ad1f..6e4ee03 100644
--- a/test.alv
+++ b/test.alv
@@ -1,10 +1,12 @@
-([2]use ([1]require 'math'))
-([4]use ([3]require 'osc'))
-([6]use ([5]require 'time'))
+([1]use ([2]require 'math'))
+([3]use ([4]require 'osc'))
+([5]use ([6]require 'time'))
-([17]def sin-lfo ([13]fn ([11]f)
- ([12]lfo f 'sin')))
+([7]def make-lfo ([8]fn (type)
+ ([11]fn ([9]f) ([10]lfo ([31]* f 0.5) type))))
-#([19]out '127.0.0.1' 9000 '/param/radius/set' ([18]lfo 0.2 'sin'))
-([8]out '127.0.0.1' 9000 '/param/radius/set' ([18]sin-lfo 0.1))
-([10]out '127.0.0.1' 9000 '/param/offset/set' ([15]sin-lfo 1))
+([12]def sin-lfo ([13]make-lfo 'sin'))
+
+
+([14]out '127.0.0.1' 9000 '/param/radius/set' ([15]sin-lfo 0.05))
+([16]out '127.0.0.1' 9000 '/param/offset/set' ([17]sin-lfo 0.2))