JanetDocsSourcePlaygroundTutorialsI'm Feeling luckyCommunityGitHub sign in

compwhen

core-api


    macro
    boot.janet on line 2858, column 1

    (compwhen cnd & body)

    Check the condition `cnd` at compile time -- if truthy, compile 
    `(upscope ;body)`, else compile nil.


1 exampleSign in to add an example
Loading...
# If your tooling or the compiler doesn't believe a symbol will be bound e.g.:
(def a b) # if b e.g. gets bound by some macro or pushed directly to the env

# You can wrap it with compwhen on a bool:
(var- bla false)
(compwhen bla
          (def a b))

# Whatever defines b should then set bla to true
# From: https://codeberg.org/veqq/declarative-dsls/src/branch/master/src/declarative-dsls/logic.janet
veqqqPlayground