all repos — min @ 78790b41a745cb5e67560fb7a034d0cc16fb470a

A small but practical concatenative programming language.

Added unseal operator.
h3rald h3rald@h3rald.com
Thu, 23 Feb 2017 12:05:14 +0100
commit

78790b41a745cb5e67560fb7a034d0cc16fb470a

parent

4106ec840857bc3943dad27cb56d133865633aa8

3 files changed, 16 insertions(+), 2 deletions(-)

jump to
M core/scope.nimcore/scope.nim

@@ -41,11 +41,11 @@ scope.symbols.excl(key)

return true return false -proc setSymbol*(scope: ref MinScope, key: string, value: MinOperator): bool {.discardable.}= +proc setSymbol*(scope: ref MinScope, key: string, value: MinOperator, override = false): bool {.discardable.}= result = false # check if a symbol already exists in current scope if not scope.isNil and scope.symbols.hasKey(key): - if scope.symbols[key].sealed: + if not override and scope.symbols[key].sealed: raiseInvalid("Symbol '$1' is sealed." % key) scope.symbols[key] = value result = true
M lib/min_lang.nimlib/min_lang.nim

@@ -745,6 +745,13 @@ var s = i.scope.getSymbol(sym.getString)

s.sealed = true i.scope.setSymbol(sym.getString, s) + .symbol("unseal") do (i: In): + var sym: MinValue + i.reqStringLike sym + var s = i.scope.getSymbol(sym.getString) + s.sealed = false + i.scope.setSymbol(sym.getString, s, true) + .symbol("quote-bind") do (i: In): var s, m: MinValue i.reqString(s)
M tests/lang.mintests/lang.min

@@ -130,6 +130,13 @@

(((2 :a1 'a1 seal 3 :a1) ("failed")) try "failed" ==) assert ( + 1 :a1 + 'a1 seal + 'a1 unseal + 2 :a1 + 2 a1 ==) assert + + ( ( (((error "TestError")(message "Test Message")) raise) ('error dget)