Ivm
vm for a dynamically typed language
Install / Use
/learn @zhengyao-lin/IvmREADME
ivm
ivm is a simple vm built for a prototype-based language ink <br>
Prerequisites
cmake >= 2.8
gcc >= 4.8.4 or clang >= 3.0
Build
Build using cmake
cmake -DVERSION=release
make
After Building
run tests or anything you write
make test
build/bin/ink hello.ink
Examples(of ink)
ink is a dynamically-typed language with...
Weird grammar
// js-like prototype mechanism
list.proto.map = fn f:
[ f(i) for loc i in base ]
// partial applied function
[ 1, 2, 3 ].
map(1 .+(_)).
map {
i -> i * 2
}.
map(print)
Natively supported coroutine
loc c = fork fn [ (yield i * 2) for loc i in range(10) ]
while c.alive():
print(resume c)
All sorts of overloading(which is bad)...
// context overload
loc = loc.clone()
list.proto.reduce = fn f: {
assert base.size() > 1
loc init = base[0]
for loc e in base.slice(1):
init = f(init, e)
init
}
list.proto.map = fn f: [ f(i) for loc i in base ]
// is capital or non-capital letter
// custom operators
string.proto.+? =
fn c = base.ord(): c >= "A".ord() && c <= "Z".ord()
string.proto.-? =
fn c = base.ord(): c >= "a".ord() && c <= "z".ord()
string.proto.~ = fn:
base.
chars().
map(fn c:
if +? c:
c.ord() - "A".ord() + "a".ord()
elif -? c:
c.ord() - "a".ord() + "A".ord()
else:
c.ord()
).
map(fn c: c.char()).
reduce(fn i, a: i + a)
print(~"hELLO, WORLD!")
... And tolerable performance
loc fib = fn n:
n < 2 ?
1 : fib(n - 1) + fib(n - 2)
print(fib(30))
more tests and examples can be found in test and test/examples folders
Related Skills
node-connect
347.2kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
108.0kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
347.2kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
347.2kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
