all repos — min @ 0e3b6568b42f420ddedf2a06ef7c28f390d6557f

A small but practical concatenative programming language.

lang enhancements.
h3rald h3rald@h3rald.com
Sat, 17 Sep 2016 16:58:42 +0200
commit

0e3b6568b42f420ddedf2a06ef7c28f390d6557f

parent

9e1e4ed24522a4c406d8da61b4e1b5e62b2ad6c6

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

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

@@ -107,7 +107,15 @@ i.reqQuotation code

code.filename = i.filename i.unquote("<module>", code) i.scope.symbols[name.getString] = MinOperator(kind: minValOp, val: @[code].newVal) - + + .symbol("scope?") do (i: In): + var q: MinValue + i.reqQuotation q + if not q.scope.isNil: + i.push true.newVal + else: + i.push false.newVal + .symbol("import") do (i: In): var mdl, rawName: MinValue var name: string

@@ -173,9 +181,12 @@ .symbol("inspect") do (i: In):

var scope: MinValue i.reqQuotation scope var symbols = newSeq[MinValue](0) - for s in scope.scope.symbols.keys: - symbols.add s.newVal - i.push symbols.newVal + if scope.scope.isNil: + i.push symbols.newVal + else: + for s in scope.scope.symbols.keys: + symbols.add s.newVal + i.push symbols.newVal # ("SomeError" "message") .symbol("raise") do (i: In):
M tests/lang.mintests/lang.min

@@ -37,6 +37,12 @@ ) :defmod

(defmod symbols "mymath" contains) assert + (defmod mymath scope?) assert + + (() scope? false ==) assert + + (() inspect () ==) assert + (defmod 'mymath import symbols "myplus" contains) assert (defmod 'mymath import 2 3 myplus 5 ==) assert