aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authors-ol <s-ol@users.noreply.github.com>2020-04-24 18:43:51 +0000
committers-ol <s-ol@users.noreply.github.com>2020-04-24 18:43:51 +0000
commitf6378eaf43c00cb41065fa6fc93af0c4efcd71c3 (patch)
treec1c14b2640e8e2afda18765ba93d41b3bbba6900
parentfix alv-wx, logging (diff)
downloadalive-f6378eaf43c00cb41065fa6fc93af0c4efcd71c3.tar.gz
alive-f6378eaf43c00cb41065fa6fc93af0c4efcd71c3.zip
remove AST:quote()
-rw-r--r--alv/ast.moon7
-rw-r--r--alv/base/fndef.moon4
-rw-r--r--alv/builtin.moon23
-rw-r--r--alv/cell.moon11
-rw-r--r--alv/stream/value.moon5
-rw-r--r--spec/cell_spec.moon19
-rw-r--r--spec/value_spec.moon7
7 files changed, 12 insertions, 64 deletions
diff --git a/alv/ast.moon b/alv/ast.moon
index a25d1cd..044e330 100644
--- a/alv/ast.moon
+++ b/alv/ast.moon
@@ -16,13 +16,6 @@
-- @tparam Scope scope the scope to evaluate in
-- @treturn Result the evaluation result
- --- quote this AST Node, preserving its identity.
- --
- --- Returns a mutable copy of this Node that shares its identity.
- --
- -- @function quote
- -- @treturn AST
-
--- create a clone with its own identity.
--
-- creates a clone of this Cell with its own identity by prepending a `parent`
diff --git a/alv/base/fndef.moon b/alv/base/fndef.moon
index b79ad85..f8858d3 100644
--- a/alv/base/fndef.moon
+++ b/alv/base/fndef.moon
@@ -13,8 +13,8 @@ class FnDef
--- create a new instance
--
-- @classmethod
- -- @tparam {Value,...} params (`AST:quote`d) naming the function parameters
- -- @tparam AST body (`AST:quote`d) expression the function evaluates to
+ -- @tparam {Value,...} params (unevaluated) naming the function parameters
+ -- @tparam AST body (unevaluated) expression the function evaluates to
-- @tparam Scope scope the lexical scope the function was defined in (closure)
new: (@params, @body, @scope) =>
diff --git a/alv/builtin.moon b/alv/builtin.moon
index 022c40c..c80e483 100644
--- a/alv/builtin.moon
+++ b/alv/builtin.moon
@@ -58,7 +58,7 @@ Define the symbols `sym1`, `sym2`, … to resolve to the values of `val-expr1`,
children = L\push ->
return for i=1,#tail,2
name, val_expr = tail[i], tail[i+1]
- name = (name\quote scope)\unwrap 'sym'
+ name = name\unwrap 'sym'
with val_expr\eval scope
scope\set name, \make_ref!
@@ -117,7 +117,7 @@ current scope."
assert #tail > 0, "'import' requires at least one arguments"
children = for i, child in ipairs tail
- name = child\quote(scope)\unwrap 'sym'
+ name = child\unwrap 'sym'
with COPILOT\require name
scope\set name, \make_ref!
Result :children
@@ -136,7 +136,7 @@ Requires modules `sym1`, `sym2`, … and merges them into the current scope."
assert #tail > 0, "'import' requires at least one arguments"
children = for i, child in ipairs tail
- with COPILOT\require child\quote(scope)\unwrap 'sym'
+ with COPILOT\require child\unwrap 'sym'
scope\use .value\unwrap 'scope'
Result :children
@@ -150,9 +150,9 @@ Evaluate `expr1`, `expr2`, … in a new Scope and return scope."
value: class extends Builtin
eval: (scope, tail) =>
- scope = Scope scope
- children = [expr\eval scope for expr in *tail]
- Result :children, value: ValueStream.wrap scope
+ new_scope = Scope scope
+ children = [expr\eval new_scope for expr in *tail]
+ Result :children, value: ValueStream.wrap new_scope
export_star = ValueStream.meta
meta:
@@ -175,7 +175,7 @@ Copies the containing scope if no symbols are given."
result
else
for child in *tail
- name = child\quote(scope)\unwrap 'sym'
+ name = child\unwrap 'sym'
with result = scope\get name
new_scope\set name, result
@@ -199,9 +199,8 @@ function is invoked."
assert params.__class == Cell, "'fn's first argument has to be an expression"
param_symbols = for param in *params.children
assert param.type == 'sym', "function parameter declaration has to be a symbol"
- param\quote scope
+ param
- body = body\quote scope
Result value: with ValueStream.wrap FnDef param_symbols, body, scope
.meta = {
summary: "(user defined function)"
@@ -224,13 +223,11 @@ function is invoked."
assert #tail == 3, "'defn' takes exactly three arguments"
{ name, params, body } = tail
- name = name\quote(scope)\unwrap 'sym'
+ name = name\unwrap 'sym'
assert params.__class == Cell, "'defn's second argument has to be an expression"
param_symbols = for param in *params.children
assert param.type == 'sym', "function parameter declaration has to be a symbol"
- param\quote scope
-
- body = body\quote scope
+ param
value = with ValueStream.wrap FnDef param_symbols, body, scope
.meta =
diff --git a/alv/cell.moon b/alv/cell.moon
index d341dde..e9125d5 100644
--- a/alv/cell.moon
+++ b/alv/cell.moon
@@ -86,17 +86,6 @@ class Cell
Builtin\eval_cell @, scope, head
- --- quote this Cell, preserving its identity.
- --
- -- Recursively quotes children, but preserves identity (i.e, shares the
- -- `Tag`). A quoted Cell may only be 'used' once. If you want to `eval` a
- -- `Cell` multiple times, use `clone`.
- --
- -- @treturn Cell
- quote: =>
- children = [child\quote scope for child in *@children]
- Cell @tag, children, @white
-
--- create a clone with its own identity.
--
-- creates a clone of this Cell with its own identity by prepending a `parent`
diff --git a/alv/stream/value.moon b/alv/stream/value.moon
index 98720c9..575b995 100644
--- a/alv/stream/value.moon
+++ b/alv/stream/value.moon
@@ -124,11 +124,6 @@ class ValueStream extends Stream
else
error "cannot evaluate #{@}"
- --- quote this literal constant.
- --
- -- @treturn ValueStream self
- quote: => @
-
--- stringify this literal constant.
--
-- Throws an error if `raw` is not set.
diff --git a/spec/cell_spec.moon b/spec/cell_spec.moon
index f58cb50..673fedf 100644
--- a/spec/cell_spec.moon
+++ b/spec/cell_spec.moon
@@ -11,25 +11,6 @@ setup -> reg\grab!
teardown -> reg\release!
describe 'Cell', ->
- describe 'when quoted', ->
- with hello_world\quote!
- it 'stays equal', ->
- assert.is.equal Cell, .__class
- assert.is.equal (ValueStream.sym 'hello'), \head!
- assert.is.same { ValueStream.str 'world' }, \tail!
-
- it 'shares the tag', ->
- assert.is.equal hello_world.tag, .tag
-
- with two_plus_two\quote!
- it 'stays equal', ->
- assert.is.equal Cell, .__class
- assert.is.equal (ValueStream.sym '+'), \head!
- assert.is.same { (ValueStream.num 2), (ValueStream.num 2) }, \tail!
-
- it 'shares the tag', ->
- assert.is.equal two_plus_two.tag, .tag
-
describe 'when cloned', ->
parent = Tag.blank '1'
with hello_world\clone parent
diff --git a/spec/value_spec.moon b/spec/value_spec.moon
index e867a70..7a68199 100644
--- a/spec/value_spec.moon
+++ b/spec/value_spec.moon
@@ -135,13 +135,6 @@ describe 'ValueStream', ->
assert_eval 'hello', ValueStream.str "world"
assert_eval 'goodbye', ValueStream.sym "again"
- it ':quote s literals as themselves', ->
- assert_noop = (val) -> assert.is.equal val, val\quote!
-
- assert_noop ValueStream.num 2
- assert_noop ValueStream.str 'hello'
- assert_noop ValueStream.sym 'world'
-
it ':clone sliterals as themselves', ->
assert_noop = (val) -> assert.is.equal val, val\clone!