Deprecated some symbols.
h3rald h3rald@h3rald.com
Sat, 09 Jan 2021 11:48:32 +0100
9 files changed,
7 insertions(+),
141 deletions(-)
M
minpkg/core/interpreter.nim
→
minpkg/core/interpreter.nim
@@ -189,14 +189,6 @@ if not val.obj.isNil:
v.obj = val.obj return v -proc applyDict*(i: In, val: MinValue): MinValue {.gcsafe, extern:"min_exported_symbol_$1".}= - # Assuming val is a dictionary - var v = i.copyDict(val) - for item in v.dVal.pairs: - var value = item.val.val - v.scope.symbols[item.key] = MinOperator(kind: minValOp, val: i.callValue(value), sealed: false) - return v - proc apply*(i: In, op: MinOperator) {.gcsafe, extern:"min_exported_symbol_$1".}= if op.kind == minProcOp: op.prc(i)@@ -426,5 +418,4 @@ return i.load(s, true)
# Inherit file/line/column from current symbol proc pushSym*(i: In, s: string) = - i.push MinValue(kind: minSymbol, symVal: s, filename: i.currSym.filename, line: i.currSym.line, column: i.currSym.column, outerSym: i.currSym.symVal) - + i.push MinValue(kind: minSymbol, symVal: s, filename: i.currSym.filename, line: i.currSym.line, column: i.currSym.column, outerSym: i.currSym.symVal)
M
minpkg/lib/min_lang.nim
→
minpkg/lib/min_lang.nim
@@ -125,17 +125,6 @@ if not f.fileExists:
raiseInvalid("File '$1' does not exist." % file) i.push i.require(f) - def.symbol("read") do (i: In): - let vals = i.expect("'sym") - let s = vals[0] - var file = s.getString - if not file.endsWith(".min"): - file = file & ".min" - info("[read] File: ", file) - if not file.fileExists: - raiseInvalid("File '$1' does not exist." % file) - i.push i.read file - def.symbol("raw-args") do (i: In): var args = newSeq[MinValue](0) for par in commandLineParams():@@ -311,12 +300,9 @@ var ed = initEditor()
i.push ed.readLine().newVal def.symbol("apply") do (i: In): - let vals = i.expect("quot|dict") + let vals = i.expect("quot") var prog = vals[0] - if prog.kind == minQuotation: - i.apply prog - else: - i.push i.applyDict(prog) + i.apply prog def.symbol("symbols") do (i: In): var q = newSeq[MinValue](0)@@ -894,12 +880,6 @@ def.symbol("expect") do (i: In):
var q: MinValue i.reqQuotationOfSymbols q i.push(i.expect(q.qVal.mapIt(it.getString())).reversed.newVal) - - def.symbol("reverse-expect-dequote") do (i: In): - var q: MinValue - i.reqQuotationOfSymbols q - var req = i.expect(q.qVal.reversed.mapIt(it.getString())).newVal - i.dequote(req) def.symbol("infix-dequote") do (i: In): let vals = i.expect("quot")@@ -1061,9 +1041,6 @@
def.symbol("->") do (i: In): i.pushSym("dequote") - def.symbol("--") do (i: In): - i.pushSym("reverse-expect-dequote") - def.symbol("::") do (i: In): i.pushSym("operator")
M
minpkg/lib/min_logic.nim
→
minpkg/lib/min_logic.nim
@@ -121,23 +121,6 @@ let vals = i.expect("bool", "bool")
let a = vals[0] let b = vals[1] i.push newVal(a.boolVal and b.boolVal) - - def.symbol("dequote-and") do (i: In): - let vals = i.expect("a", "a") - var a = vals[0] - var b = vals[1] - i.dequote(b) - let resB = i.pop - if (resB.isBool and resB.boolVal == false): - i.push(false.newVal) - else: - i.dequote(a) - let resA = i.pop - if not resA.isBool: - raiseInvalid("Result of first quotation is not a boolean value") - if not resB.isBool: - raiseInvalid("Result of second quotation is not a boolean value") - i.push newVal(resA.boolVal and resB.boolVal) def.symbol("expect-all") do (i: In): let vals = i.expect("quot")@@ -162,23 +145,6 @@ let vals = i.expect("bool", "bool")
let a = vals[0] let b = vals[1] i.push newVal(a.boolVal or b.boolVal) - - def.symbol("dequote-or") do (i: In): - let vals = i.expect("a", "a") - var a = vals[0] - var b = vals[1] - i.dequote(b) - let resB = i.pop - if (resB.isBool and resB.boolVal == true): - i.push(true.newVal) - else: - i.dequote(a) - let resA = i.pop - if not resA.isBool: - raiseInvalid("Result of first quotation is not a boolean value") - if resB.isBool: - raiseInvalid("Result of second quotation is not a boolean value") - i.push newVal(resA.boolVal and resB.boolVal) def.symbol("expect-any") do (i: In): let vals = i.expect("quot")
M
next-release.md
→
next-release.md
@@ -7,3 +7,4 @@ * Refacored code to satisfy nimble package structure.
* Now caching required modules so that their code is executed only once. * Added **line-info** symbol returning a dictionary containing the current filename, line and column numbers. * Added **dsdelete!**, **dspost!**, **dsput!**, **dswrite!**. +* **REMOVED** the following symbols because redundant or pointless: **dequote-and**, **dequote-or**, **reverse-expect-dequote** (and **--**), **read**. Also, **apply** no longer works on dictionaries, only quotations.
M
site/contents/get-started.md
→
site/contents/get-started.md
@@ -77,7 +77,6 @@ * The {#link-module||sys#}
* The following operators: * {#link-operator||lang||load#} * {#link-operator||lang||require#} - * {#link-operator||lang||read#} * {#link-operator||lang||to-json#} * {#link-operator||lang||from-json#} * {#link-operator||lang||raw-args#}
M
site/contents/reference-lang.md
→
site/contents/reference-lang.md
@@ -34,8 +34,6 @@ {#sig||<||load-symbol#}
{#alias||->||dequote#} -{#alias||\-\-||reverse-expect-dequote#} - {#alias||>>||prefix-dequote#} {#alias||><||infix-dequote#}@@ -56,10 +54,7 @@
{#alias||=||quote-define#} {#op||apply||{{q}}|{{d}}||({{a0p}})|{{{a0p}}}|| -> This operator can be used on a quotation or a dictionary: -> -> * If a quotation {{q}} is passed, it returns a new quotation obtained by evaluating each element of {{q}} in a separate stack. -> * If a dictionary {{d}} (with values and keys) is passed, it returns a new dictionary obtained by evaluating each value in the dict that is a symbol in a separate stack (values that aren't symbols stay as they are).#} +Returns a new quotation obtained by evaluating each element of {{q}} in a separate stack. #} {#op||args||{{none}}||{{q}}|| Returns a list of all arguments passed to the current program.#}@@ -152,7 +147,6 @@ > > `(int string num) expect (3.4 "test" 1) ==`#}
{#op||expect-empty-stack||{{none}}||{{none}}|| Raises an error if the stack is not empty.#} - {#op||float||{{any}}||{{flt}}|| > Converts {{any}} to an integer value based on the following rules:@@ -379,26 +373,14 @@
{#op||raise||{{e}}||{{none}}|| Raises the error specified via the dictionary {{e}}.#} -{#op||read||{{sl}}||{{q}}|| -Reads and parses the specified {{m}} file {{sl}} and returns a quoted program {{q}}. #} +{#op||raw-args||{{none}}||{{q}}|| +Returns a list of all arguments and (non-parsed) options passed to the current program.#} {#op||remove-symbol||{{sl}}||{{none}}|| Removes the symbol {{sl}} from the [.min\_symbols](class:file) file. #} {#op||require||{{sl}}||{{d}}|| Parses and interprets (in a separater interpreter) the specified {{m}} file {{sl}}, adding [.min](class:ext) if not specified, and returns a module dictionary {{d}} containing all the symbols defined in {{sl}}. #} - -{#op||reverse-expect-dequote||{{q1}}||{{a0p}}|| -> Validates the first _n_ elements of the stack against the type descriptions specified in {{q1}} (_n_ is {{q1}}'s length) in reverse order and if all the elements are valid restores them on the stack. -> -> > %sidebar% -> > Example -> -> > The following program maps the three values on the stack to three symbols, after validating them: -> > -> > 1 3.5 true -> > (int float bool) -- :my-int :my-float :my-bool - #} {#op||return||{{none}}||{{none}}|| If used within the body quotation of an operator definition, causes the interpreter to stop pushing further body elements on the stack and start pushing tbe operator output values on the stack.
M
site/contents/reference-logic.md
→
site/contents/reference-logic.md
@@ -44,49 +44,6 @@
{#op||boolean?||{{any}}||{{b}}|| Returns {{t}} if {{any}} is a boolean, {{f}} otherwise. #} -{#op||dequote-and||{{a1}} {{a2}}||{{b}}|| -> Short-circuited logical and. It performs the following operations: -> -> 1. Pops {{a1}} and {{a2}} off the stack. -> 2. Dequotes {{a1}}, if {{f}} is on the stack, it pushes {{f}} on the stack and stops, otherwise it carries on. -> 3. Dequotes {{a2}}. -> 4. If {{a2}} is {{t}}, it pushes {{t}} on the stack. -> -> > %note% -> > Note -> > -> > {{a1}} (and {{a2}}, if dequoted) must evaluate to a boolean value, otherwise an exception is raised. -> -> > %sidebar% -> > Example -> > -> > The following program returns {{f}} and never executes the second quotation. -> > -> > "test" :x (x number?) (x 5 <) dequote-and - - #} - -{#op||dequote-or||{{a1}} {{a2}}||{{b}}|| -> Short-circuited logical or. It performs the following operations: -> -> 1. Pops {{a1}} and {{a2}} off the stack. -> 2. Dequotes {{a1}}, if {{t}} is on the stack, it pushes {{t}} on the stack and stops, otherwise it carries on. -> 3. Dequotes {{a2}}. -> 4. If {{a2}} is {{f}}, it pushes {{f}} on the stack. -> -> > %note% -> > Note -> > -> > {{a1}} (and {{a2}}, if dequoted) must evaluate to a boolean value, otherwise an exception is raised. -> -> > %sidebar% -> > Example -> > -> > The following program returns {{t}} and never executes the second quotation. -> > -> > "test" :x (x string?) (x quotation?) dequote-or - #} - {#op||dictionary?||{{any}}||{{b}}|| Returns {{t}} if {{any}} is a dictionary, {{f}} otherwise. #}
M
tests/lang.min
→
tests/lang.min
@@ -203,10 +203,6 @@ ) assert
(3.4 "test" 1 (int string num) expect (3.4 "test" 1) ==) assert - ("2 2 +" "testread.min" fwrite "testread.min" read (2 2 +) ==) assert - - "testread.min" rm - ("aaa bbb ccc 2 2 + (2 3 4)" parse (aaa bbb ccc 2 2 + (2 3 4)) ==) assert (lite? false ==) assert
M
tests/logic.min
→
tests/logic.min
@@ -149,9 +149,6 @@ (3 "a" == not) assert
(1 () != true) assert (3.3 'test == not) assert - ("a" :x (x number?) (x 6 <) dequote-and not) assert - (1 :x (x number?) (dsagasdgsg) dequote-or) assert - ( ( (true)