aboutsummaryrefslogtreecommitdiffstats
path: root/core/base/fndef.moon
diff options
context:
space:
mode:
Diffstat (limited to 'core/base/fndef.moon')
-rw-r--r--core/base/fndef.moon22
1 files changed, 22 insertions, 0 deletions
diff --git a/core/base/fndef.moon b/core/base/fndef.moon
new file mode 100644
index 0000000..b6c284b
--- /dev/null
+++ b/core/base/fndef.moon
@@ -0,0 +1,22 @@
+----
+-- `alive` user-function definition (`fndef`).
+--
+-- When called, expands to its body with params bound to the fn arguments (see
+-- `invoke.fn_invoke`).
+--
+-- @classmod FnDef
+
+class FnDef
+ --- create a new instance
+ --
+ -- @tparam {Value,...} params (`\quote`d) naming the function parameters
+ -- @tparam AST body (`\quote`d) expression the function evaluates to
+ -- @tparam Scope scope the lexical scope the function was defined in (closure)
+ new: (@params, @body, @scope) =>
+
+ __tostring: =>
+ "(fn (#{table.concat [p\stringify! for p in *@params], ' '}) ...)"
+
+{
+ :FnDef
+}