(.using [library [lux "*" [extension {"+" directive:}] ["[0]" meta] ["[0]" static] [abstract ["[0]" monad {"+" do}]] [control ["<>" parser ["<[0]>" code]]] [data [text ["%" format]] [collection ["[0]" list ("[1]#[0]" monad mix)] ["[0]" set]]] ["[0]" macro [syntax {"+" syntax:}] ["[0]" code]] [math ["[0]" random]] [target ["/" lua]] [tool [compiler ["[0]" phase] [meta [cache ["[0]" dependency "_" ["[1]" artifact]]]] [language [lux ["[0]" generation] ["[0]" directive] [analysis ["[0]" type]]]]]]]]) (def: definition (-> Code (Meta [Text Code])) (|>> (list) (.result (<| .form (<>.after (.text! "lux def")) (<>.before .any) ($_ <>.and .local_symbol .any))) meta.lifted)) ... [15.2 – Privacy](https://www.lua.org/pil/15.2.html) ... [15.3 – Packages and Files](https://www.lua.org/pil/15.3.html) ... [15.4 – Using the Global Table](https://www.lua.org/pil/15.4.html) (with_expansions [ (static.random (|>> %.nat (%.format "lua export ") code.text) random.nat)] (directive: ( self phase archive [name .text term .any]) (do [! phase.monad] [next directive.analysis [_ term] (<| directive.lifted_analysis type.inferring (next archive term)) next directive.synthesis term (directive.lifted_synthesis (next archive term)) dependencies (directive.lifted_generation (dependency.dependencies archive term)) next directive.generation [interim_artifacts term] (directive.lifted_generation (generation.with_interim_artifacts archive (next archive term))) _ (directive.lifted_generation (do ! [@self (generation.learn_custom name (list#mix set.has dependencies interim_artifacts)) .let [$exports (/.var "_REQUIREDNAME") $global (/.var "_G") exporting? (/.not (/.= /.nil $exports)) no_exports? (/.= /.nil (/.item $exports $global)) initialize_exports! (/.set (list (/.item $exports $global)) (/.table (list))) export_definition! (/.set (|> $global (/.item $exports) (/.item (/.string name)) (list)) (/.var name)) export! (/.when exporting? ($_ /.then (/.when no_exports? initialize_exports!) export_definition! ))] _ (generation.execute! ($_ /.then (/.set (list (/.var name)) term) export!)) _ (generation.save! @self {.#None} ($_ /.then (/.local/1 (/.var name) term) export!))] (generation.log! (%.format "Export " (%.text name)))))] (in directive.no_requirements))) (syntax: .public (export: [exports (<>.many .any)]) (let [! meta.monad] (|> exports (monad.each ! macro.expansion) (# ! each (|>> list#conjoint (monad.each ! ..definition))) (# ! conjoint) (# ! each (list#each (function (_ [name term]) (` ( (~ (code.text name)) (~ term))))))))))