1
1
mirror of https://github.com/kanaka/mal.git synced 2024-09-20 10:07:45 +03:00

crystal: implement mal in Mal module

This commit is contained in:
rhysd 2015-05-02 15:44:10 +09:00
parent 85c1b0c0d8
commit 2c436e30c0
2 changed files with 15 additions and 12 deletions

View File

@ -8,15 +8,18 @@ lib LibReadline
fun add_history(line : UInt8*)
end
def my_readline(prompt = "")
line = LibReadline.readline(prompt)
if line
LibReadline.add_history(line)
String.new(line)
else
nil
end
ensure
LibC.free(line as Void*) if line
end
module Mal
def my_readline(prompt = "")
line = LibReadline.readline(prompt)
if line
LibReadline.add_history(line)
String.new(line)
else
nil
end
ensure
LibC.free(line as Void*) if line
end
end

View File

@ -21,6 +21,6 @@ def rep(x)
read(eval(print(x)))
end
while line = my_readline("user> ")
while line = Mal::my_readline("user> ")
puts rep(line)
end