aboutsummaryrefslogtreecommitdiffstats
path: root/docs/guide/importing-operators.md
diff options
context:
space:
mode:
authors-ol <s-ol@users.noreply.github.com>2020-05-17 15:41:56 +0000
committers-ol <s+removethis@s-ol.nu>2025-03-02 14:24:49 +0000
commit406da94f13f47a9c7aef6b9c11cfe057772630cf (patch)
treedd98e12eddd421e2883c90239cb10225bb75b07e /docs/guide/importing-operators.md
parentbuiltin/trae: print literals literally (diff)
downloadalive-406da94f13f47a9c7aef6b9c11cfe057772630cf.tar.gz
alive-406da94f13f47a9c7aef6b9c11cfe057772630cf.zip
split guide into multiple pages
Diffstat (limited to 'docs/guide/importing-operators.md')
-rw-r--r--docs/guide/importing-operators.md26
1 files changed, 26 insertions, 0 deletions
diff --git a/docs/guide/importing-operators.md b/docs/guide/importing-operators.md
new file mode 100644
index 0000000..4321e7a
--- /dev/null
+++ b/docs/guide/importing-operators.md
@@ -0,0 +1,26 @@
+Apart from [trace][], there are only very little builtin operators in `alv` -
+you can see all of them in the *builtins* section of the [reference][:/:].
+All of the 'real' functionality of `alv` is grouped into *modules*, that have
+to be loaded individually. *Modules* help organize all of the operators so that
+it is less overwhelming to look for a concrete feature. It is also possible to
+create your own plugins as new modules, which will be covered in another guide
+soon.
+
+Let's try using the [`+` operator][:math/+:] from the [math/][] module. To use
+operators from a module, we need to tell `alv` to load it first: We can load
+*all* the operators from the [math/][] module into the current scope using the
+[import*][] builtin:
+
+ (import* math)
+ (trace (+ 1 2))
+
+prints
+
+ trace (+ 1 2): <num= 3>
+
+Because it can get a bit confusing when all imported operators are mixed in the
+global scope, it is also possible to load the module into its own scope and use
+it with a prefix. This is what the [import][] builtin is for:
+
+ (import math)
+ (trace (math/+ 1 2))