I hereby claim:
- I am bakpakin on github.
- I am calsrose (https://keybase.io/calsrose) on keybase.
- I have a public key ASD62xnhgH6qEJAsaF1kQTKnIh0fDV-TGC_zX43VZpx7QAo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
| SPECIALS['lua'] = function(ast, scope, parent) | |
| table.insert(parent, {leaf = ast[2], ast = ast}) | |
| end |
| -- (lua "print('hello!')") -> prints hello, evaluates to nil | |
| -- (lua "print 'hello!'" "10") -> prints hello, evaluates to the number 10 | |
| -- (lua nil "{1,2,3}") -> Evaluates to a table literal | |
| SPECIALS['lua'] = function(ast, scope, parent) | |
| assertCompile(#ast == 2 or #ast == 3, | |
| "expected 2 or 3 arguments in 'lua' special form", ast) | |
| if ast[2] ~= nil then | |
| table.insert(parent, {leaf = tostring(ast[2]), ast = ast}) | |
| end | |
| if #ast == 3 then |
| (fn line-iter [packets] | |
| (var buf "") | |
| (fn recur [] | |
| (local (residual rest) (: buf :match "^(.*)\r\n(.*)$")) | |
| (if residual | |
| (do (set buf rest) residual) | |
| (let [packet (packets)] | |
| (when packet | |
| (set buf (.. buf packet)) | |
| (recur)))))) |
| (import shlib) | |
| (defn ansi | |
| "Take a string made by concatenating xs and colorize it for an ANSI terminal." | |
| [code & xs] | |
| (string "\e[" code "m" ;xs "\e[0m")) | |
| (defn cmd | |
| "Run a quick command and strip trailing newline." | |
| [s] |
| diff --git a/fennel.lua b/fennel.lua | |
| index 56ee209..a951d5f 100644 | |
| --- a/fennel.lua | |
| +++ b/fennel.lua | |
| @@ -422,6 +422,9 @@ local function makeScope(parent) | |
| symmeta = setmetatable({}, { | |
| __index = parent and parent.symmeta | |
| }), | |
| + includes = setmetatable({}, { | |
| + __index = parent and parent.includes |
| static JanetFunction *global_cb = NULL; | |
| Janet register_callback(int32_t argc, Janet *argv) { | |
| janet_fixarity(argc, 1); | |
| JanetFunction *cb = janet_getfunciton(argv, 0); | |
| global_cb = cb; | |
| // Make sure the callback is not garbage collected while waiting | |
| janet_gcroot(argv[0]); | |
| return janet_wrap_nil(); | |
| } |
| (defn http-get | |
| "Get some HTTP using curl" | |
| [url] | |
| (with [f (file/popen (string "curl -s " url))] | |
| (:read f :all))) | |
| (http-get "https://www.google.com") |
| core_modules = unpack_url( | |
| url="https://github.com/buildpackagedeploy/hermes-core/archive/4f92d8aaa001406e58513929710027bc4b733cf2.tar.gz", | |
| hash="sha256:db931edc4ddf71a8d749a09f14ed5d771f7099b898273176111452c4b9700983", | |
| ) | |
| bootstrap_env = load_module(core_modules, "bootstrap.hpkg").bootstrap_env | |
| janet_src = fetch_url( | |
| url="https://github.com/janet-lang/janet/archive/v1.2.0.tar.gz", | |
| hash="sha256:e824ee2da7dffab10bb7ce28917b57a82df82eebf713ad2bbb74ed7be36bd4f4" |
| diff --git a/fennel.lua b/fennel.lua | |
| index c079085..dd7252f 100644 | |
| --- a/fennel.lua | |
| +++ b/fennel.lua | |
| @@ -825,7 +825,8 @@ local function keepSideEffects(exprs, chunk, start, ast) | |
| if se.type == 'expression' and se[1] ~= 'nil' then | |
| emit(chunk, ('do local _ = %s end'):format(tostring(se)), ast) | |
| elseif se.type == 'statement' then | |
| - emit(chunk, tostring(se), ast) | |
| + local code = tostring(se) |