JanetDocsSourcePlaygroundTutorialsI'm Feeling luckyCommunityGitHub sign in

import

core-api


    macro
    boot.janet on line 3249, column 1

    (import path & args)

    Import a module. First requires the module, and then merges its 
    symbols into the current environment, prepending a given prefix as 
    needed. (use the :as or :prefix option to set a prefix). If no 
    prefix is provided, use the name of the module as a prefix. One can 
    also use "`:export true`" to re-export the imported symbols. If 
    "`:exit true`" is given as an argument, any errors encountered at 
    the top level in the module will cause `(os/exit 1)` to be called. 
    Dynamic bindings will NOT be imported. Use :fresh with a truthy 
    value to bypass the module cache. Use `:only [foo bar baz]` to only 
    import select bindings into the current environment.


3 examplesSign in to add an example
Loading...
# To make a package conditionally export:

# A package can see whether another module was already imported,
# and conditionally act and e.g. import it and rebind/export some symbols:
(var- bla false)
(compwhen  (not (some |(string/has-suffix? "dataframes.janet" $) (keys module/cache)))
           (import declarative-dsls/dataframes :as "no" :export false)
           (set bla true))
(compwhen bla
          (def print-as-table no/print-as-table)
          (def select no/select)
          (def populate-df! no/populate-df!)
          (def rows->dataframe no/rows->dataframe)
          (def dataframe->rows no/dataframe->rows))

# From: https://codeberg.org/veqq/declarative-dsls/src/branch/master/src/declarative-dsls/logic.janet
veqqqPlayground
# :as sets a /

(import /deeper/inside :prefix "" :export true)
# @{_ @{:value <cycle 0>} cat @{:private false}}
(import /deeper/inside :as "" :export true)
# @{/cat @{:private false} _ @{:value <cycle 0>} cat @{:private false}}

veqqqPlayground
In order to use :fresh, write:
(import path :fresh true)
SaikyunPlayground