all repos — min @ 64541715fad5b3671159b42b9ed82df3481a425b

A small but practical concatenative programming language.

examples/dyntest.nim

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
## This is all you need to create a min module in Nim
## Compile with `nim c --app:lib --noMain -d:release -l:"-undefined dynamic_lookup" dyntest.nim`

include ../mindyn

proc dyntest*(i: In) {.rtl, dynlib, exportc.} =
  let def = i.define()
  def.symbol("myp") do (i: In):
    let vals = i.expect("num", "num")
    let a = vals[0]
    let b = vals[1]
    if a.isInt:
      if b.isInt:
        i.push newVal(a.intVal + b.intVal)
      else:
        i.push newVal(a.intVal.float + b.floatVal)
    else:
      if b.isFloat:
        i.push newVal(a.floatVal + b.floatVal)
      else:
        i.push newVal(a.floatVal + b.intVal.float)
  def.finalize("dyntest")