all repos — min @ 351a30229fb6d9ff6e37eabdad305194f330d276

A small but practical concatenative programming language.

refactor(call) Call now requires a scope as first parameter.
h3rald h3rald@h3rald.com
Fri, 03 Jun 2016 22:09:59 +0200
commit

351a30229fb6d9ff6e37eabdad305194f330d276

parent

971cdb5d8daddbb43132df2142cf90f06e83f0a4

2 files changed, 6 insertions(+), 4 deletions(-)

jump to
M lib/lang.nimlib/lang.nim

@@ -153,14 +153,16 @@

.symbol("call") do (i: In): let symbols = i.pop - if not symbols.isQuotation: - i.error(errIncorrect, "A quotation is required on the stack") + var target = i.pop + if not symbols.isQuotation or not target.isQuotation: + i.error errIncorrect, "Two quotations are required on the stack" let vals = symbols.qVal var q: MinValue if vals.len == 0: i.error errIncorrect, "No symbol to call" return let origScope = i.scope + i.scope = target.scope for c in 0..vals.len-1: if not vals[c].isStringLike: i.error(errIncorrect, "Quotation must contain only symbols or strings")
M tests/lang.mintests/lang.min

@@ -34,7 +34,7 @@ ; Extend an existing scope

(defmod (#mymath (-) :myminus) => .mymath - 5 2 %mymath:myminus 3 ==) assert + 5 2 mymath %myminus 3 ==) assert ((":mysigil" concat) ', sigil ,test "test:mysigil" ==) assert

@@ -43,7 +43,7 @@

("2 2 +" "tests/testload.min" fwrite @testload 4 ==) assert "tests/testload.min" rm - (defmod 2 2 %mymath:myplus 4 ==) assert + (defmod 2 2 mymath %myplus 4 ==) assert (1 2 3 4 getstack (1 2 3 4) ==) assert