bakpakin on master
Fix docstring. (compare)
bakpakin on master
Add testcase for issue #1005 (compare)
bakpakin on master
Get rid of disabled tracing. #1… (compare)
bakpakin on master
Address #1005 - Fix janet_call … (compare)
not sure i follow.
is it possible drop
could be applied to your situation?
do you have some sample code?
@sogaiu:matrix.org
Here's the sample code:
(peg/match '{:dd (sequence :d :d)
:sep (set "/-")
:date (sequence :dd :sep :dd)
:wsep (some (set " \t"))
:entry (group (sequence (capture :date) :wsep (capture :date)))
:main (some (thru :entry))}
"1800-10-818-9-818 16/12 17/12 19/12 20/12 11/01 12/01"
)
#returns
@["00-10" "10-81" @["16/12" "17/12"] @["19/12" "20/12"] @["11/01" "12/01"]]
I would like to remove "00-10" and "10-81" from the output.
I had thought about drop, but I didn't know how to use it in this situation. :(
:main
with (some (choice :entry 1))
, I will push a fix and file a bug report
some
lets me continue "if i can't match... etc..." repeatedly until the end of input?
run-context
correctly when i want to execute some code that has access to my current environment/functions?
Why does this work:
(defn test-func []
(print "Hello there!"))
(defn test []
(def test-func-2 (eval-string "(fn [] (test-func))" ))
(test-func-2))
(test)
but this doesn't?:
(defn test-func []
(print "Hello there!"))
(defn test []
(def test-func-2 (eval-string "(fn [] (test-func))" ))
(test-func-2))
(defn main [& args]
(test))
(pp (curenv))
before (test)
in both cases
(defn execute_pre_sync_hook []
(def path_no_extension (string (get_cfg_dir) "/hooks/pre-sync"))
(if (file_exists? (string path_no_extension ".janet"))
(do (print "Executing pre-sync-hook...")
(import* path_no_extension)
(pre-sync/pre-sync))
true))
error: cfg.janet:138:11: compile error: unknown symbol pre-sync/pre-sync
(defn execute_pre_sync_hook []
(def path (string (get_cfg_dir) "/hooks/pre-sync.janet"))
(if (file_exists? path)
(do (print "Executing pre-sync-hook...")
(def pre-sync (eval-string (slurp path)))
(pre-sync))
true))
You modify the environment in the middle of a compiled block - the block is compiled before *import
is run, because compilation always comes before evaluation. No amount of hacks will fix that. As I said, Janet is (almost) always early bound.
eval-string is not the right solution to your problem though, I can tell you that. Could you not do something like:
(defn load-hooks
"load pre and post hooks"
[module-path]
(def module (require module-path))
(def pre-sync (get-in module ['pre-sync :value]))
(pre-sync))
require
, dofile
if you want to just pass in a bare path