summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Listopadov <andreyorst@gmail.com>2021-02-17 21:16:54 +0300
committerAndrey Listopadov <andreyorst@gmail.com>2021-02-17 21:16:54 +0300
commit9fda2f3096fc51b00587dc1a0d715fdd7120651b (patch)
tree3db8f8d7d74786eb76fd26945fc067de61a3044d
parenta7047d22c756222728ec1e2cd863c4875610be6e (diff)
fix: fix some links in docs
-rw-r--r--doc/cljlib.md30
-rw-r--r--doc/macros.md16
-rw-r--r--doc/tests/test.md1
-rw-r--r--init.fnl218
-rw-r--r--macros.fnl214
-rw-r--r--tests/test.fnl22
6 files changed, 251 insertions, 250 deletions
diff --git a/doc/cljlib.md b/doc/cljlib.md
index 06bb18e..64bd6c0 100644
--- a/doc/cljlib.md
+++ b/doc/cljlib.md
@@ -43,7 +43,7 @@ Main difference is that when comparing two tables, they must have
exactly the same `__eq` metamethods, so comparing hash sets with hash
sets will work, but comparing sets with other tables works only in
Lua5.3+. Another difference is that Lua 5.2 and LuaJIT don't have
-inbuilt UTF-8 library, therefore `seq` function will not work for
+inbuilt UTF-8 library, therefore [`seq`](#seq) function will not work for
non-ASCII strings.
**Table of contents**
@@ -505,7 +505,7 @@ Function signature:
Constructs sequential table out of it's arguments.
-Sets additional metadata for function `vector?` to work.
+Sets additional metadata for function [`vector?`](#vector) to work.
### Examples
@@ -570,7 +570,7 @@ Function signature:
(first ([col]))
```
-Return first element of a table. Calls `seq` on its argument.
+Return first element of a table. Calls [`seq`](#seq) on its argument.
## `rest`
Function signature:
@@ -580,7 +580,7 @@ Function signature:
```
Returns table of all elements of a table but the first one. Calls
- `seq` on its argument.
+ [`seq`](#seq) on its argument.
## `last`
Function signature:
@@ -589,7 +589,7 @@ Function signature:
(last ([col]))
```
-Returns the last element of a table. Calls `seq` on its argument.
+Returns the last element of a table. Calls [`seq`](#seq) on its argument.
## `butlast`
Function signature:
@@ -599,7 +599,7 @@ Function signature:
```
Returns everything but the last element of a table as a new
- table. Calls `seq` on its argument.
+ table. Calls [`seq`](#seq) on its argument.
## `conj`
Function signature:
@@ -613,7 +613,7 @@ Insert `x` as a last element of a table `tbl`.
If `tbl` is a sequential table or empty table, inserts `x` and
optional `xs` as final element in the table.
-If `tbl` is an associative table, that satisfies `map?` test,
+If `tbl` is an associative table, that satisfies [`map?`](#map) test,
insert `[key value]` pair into the table.
Mutates `tbl`.
@@ -690,7 +690,7 @@ result of calling f with no arguments. If coll has only 1 item, it is
returned and f is not called. If val is supplied, returns the result
of applying f to val and the first item in coll, then applying f to
that result and the 2nd item, etc. If coll contains no items, returns
-val and f is not called. Calls `seq` on `col`.
+val and f is not called. Calls [`seq`](#seq) on `col`.
Early termination is possible with the use of [`reduced`](#reduced)
function.
@@ -795,9 +795,9 @@ Function signature:
Maps function `f` over one or more collections.
-Accepts arbitrary amount of collections, calls `seq` on each of it.
+Accepts arbitrary amount of collections, calls [`seq`](#seq) on each of it.
Function `f` must take the same amount of arguments as the amount of
-tables, passed to `mapv`. Applies `f` over first value of each
+tables, passed to [`mapv`](#mapv). Applies `f` over first value of each
table. Then applies `f` to second value of each table. Continues until
any of the tables is exhausted. All remaining values are
ignored. Returns a sequential table of results.
@@ -1009,7 +1009,7 @@ Function signature:
(dissoc ([tbl]) ([tbl key]) ([tbl key & keys]))
```
-Remove `key` from table `tbl`. Optionally takes more `keys`.
+Remove `key` from table `tbl`. Optionally takes more [`keys`](#keys).
## `remove-method`
Function signature:
@@ -1061,7 +1061,7 @@ Create ordered set.
Set is a collection of unique elements, which sore purpose is only to
tell you if something is in the set or not.
-`ordered-set` is follows the argument insertion order, unlike sorted
+[`ordered-set`](#ordered-set) is follows the argument insertion order, unlike sorted
sets, which apply some sorting algorithm internally. New items added
at the end of the set. Ordered set supports removal of items via
`tset` and [`disj`](#disj). To add element to the ordered set use
@@ -1069,7 +1069,7 @@ at the end of the set. Ordered set supports removal of items via
**Note**: Hash set prints as `@set{a b c}`, but this construct is not
supported by the Fennel reader, so you can't create sets with this
-syntax. Use `hash-set` function instead.
+syntax. Use [`ordered-set`](#ordered-set) function instead.
Below are some examples of how to create and manipulate sets.
@@ -1127,7 +1127,7 @@ oset
```
#### Equality semantics
-Both `ordered-set` and [`hash-set`](#hash-set) implement `__eq` metamethod,
+Both [`ordered-set`](#ordered-set) and [`hash-set`](#hash-set) implement `__eq` metamethod,
and are compared for having the same keys without particular order and
same size:
@@ -1157,7 +1157,7 @@ as for [`ordered-set`](#ordered-set)
**Note**: Hash set prints as `@set{a b c}`, but this construct is not
supported by the Fennel reader, so you can't create sets with this
-syntax. Use `hash-set` function instead.
+syntax. Use [`hash-set`](#hash-set) function instead.
---
diff --git a/doc/macros.md b/doc/macros.md
index 3b99c3e..d657eb8 100644
--- a/doc/macros.md
+++ b/doc/macros.md
@@ -170,14 +170,14 @@ inner expressions of `catch-clause*`, and `finally-clause?` are
wrapped in implicit `do`.
Finally clause is optional, and written as (finally body*). If
-present, it must be the last clause in the `try` form, and the only
+present, it must be the last clause in the [`try`](#try) form, and the only
`finally` clause. Note that `finally` clause is for side effects
-only, and runs either after succesful run of `try` body, or after any
+only, and runs either after succesful run of [`try`](#try) body, or after any
`catch` clause body, before returning the result. If no `catch`
clause is provided `finally` runs in implicit catch-all clause, and
trows error to upper scope using `error` function.
-To throw error from `try` to catch it with `catch` clause use `error`
+To throw error from [`try`](#try) to catch it with `catch` clause use `error`
or `assert` functions.
### Examples
@@ -274,9 +274,9 @@ Function signature:
(defonce attr-map? name expr)
```
-Works the same as [`def`](#def), but ensures that later `defonce`
+Works the same as [`def`](#def), but ensures that later [`defonce`](#defonce)
calls will not override existing bindings. Accepts same `attr-map?` as
-`def`, and sets `name` to the result of `expr`:
+[`def`](#def), and sets `name` to the result of `expr`:
``` fennel
(defonce a 10)
@@ -402,7 +402,7 @@ Transform table `from` into another table `to`. Mutates first table.
Transformation happens in runtime, but type deduction happens in
compile time if possible. This means, that if literal values passed
-to `into` this will have different effects for associative tables and
+to [`into`](#into) this will have different effects for associative tables and
vectors:
``` fennel
@@ -425,7 +425,7 @@ will not work for empty tables:
(assert-eq (into empty-table {:a 1}) [[:a 1]])
``` fennel
-If table is empty, `into` defaults to sequential table, because it
+If table is empty, [`into`](#into) defaults to sequential table, because it
allows safe conversion from both sequential and associative tables.
Type for non empty tables hidden in variables can be deduced at
@@ -495,7 +495,7 @@ Function signature:
(with-meta value meta)
```
-Attach `meta` to a `value`. When metadata feature is not enabled,
+Attach [`meta`](#meta) to a `value`. When metadata feature is not enabled,
returns the value without additional metadata.
``` fennel
diff --git a/doc/tests/test.md b/doc/tests/test.md
index 2f5f87a..c656f3b 100644
--- a/doc/tests/test.md
+++ b/doc/tests/test.md
@@ -1,5 +1,6 @@
# Test.fnl
+
**Table of contents**
- [`deftest`](#deftest)
diff --git a/init.fnl b/init.fnl
index 1ddf86d..2ccbef2 100644
--- a/init.fnl
+++ b/init.fnl
@@ -16,19 +16,19 @@ Lua 5.3.5 Copyright (C) 1994-2018 Lua.org, PUC-Rio
-- 1 4 9
```
-This example is mapping an anonymous `function` over a table,
+This example is mapping an anonymous `function' over a table,
producing new table and concatenating it with `\" \"`.
However this library also provides Fennel-specific set of
[macros](./macros.md), that provides additional facilities like
-`fn*` or `defmulti` which extend the language allowing writing code
+`fn*' or `defmulti' which extend the language allowing writing code
that looks and works mostly like Clojure.
-Each function in this library is created with `fn*`, which is a
+Each function in this library is created with `fn*', which is a
special macros for creating multi-arity functions. So when you see
function signature like `(foo [x])`, this means that this is function
-`foo`, that accepts exactly one argument `x`. In contrary, functions
-created with `fn` will produce `(foo x)` signature (`x` is not inside
+`foo', that accepts exactly one argument `x'. In contrary, functions
+created with `fn' will produce `(foo x)` signature (`x' is not inside
brackets).
Functions, which signatures look like `(foo ([x]) ([x y]) ([x y &
@@ -46,7 +46,7 @@ Main difference is that when comparing two tables, they must have
exactly the same `__eq` metamethods, so comparing hash sets with hash
sets will work, but comparing sets with other tables works only in
Lua5.3+. Another difference is that Lua 5.2 and LuaJIT don't have
-inbuilt UTF-8 library, therefore `seq` function will not work for
+inbuilt UTF-8 library, therefore `seq' function will not work for
non-ASCII strings."})
(local insert table.insert)
@@ -59,8 +59,8 @@ non-ASCII strings."})
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Utility functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(fn* core.apply
- "Apply `f` to the argument list formed by prepending intervening
-arguments to `args`, and `f` must support variadic amount of
+ "Apply `f' to the argument list formed by prepending intervening
+arguments to `args', and `f' must support variadic amount of
arguments.
# Examples
@@ -162,8 +162,8 @@ Applying `add' to different amount of arguments:
(> y (. more 1)))
false)))
-(fn* core.inc "Increase number `x` by one" [x] (+ x 1))
-(fn* core.dec "Decrease number `x` by one" [x] (- x 1))
+(fn* core.inc "Increase number `x' by one" [x] (+ x 1))
+(fn* core.dec "Decrease number `x' by one" [x] (- x 1))
(local utility-doc-order
[:apply :add :sub :mul :div :le :lt :ge :gt :inc :dec])
@@ -177,14 +177,14 @@ Applying `add' to different amount of arguments:
t)))
(fn* core.map?
- "Check whether `tbl` is an associative table.
+ "Check whether `tbl' is an associative table.
Non empty associative tables are tested for two things:
-- `next` returns the key-value pair,
-- key, that is returned by the `next` is not equal to `1`.
+- `next' returns the key-value pair,
+- key, that is returned by the `next' is not equal to `1`.
Empty tables can't be analyzed with this method, and `map?' will
-return `false`. If you need this test pass for empty table, see
+return `false'. If you need this test pass for empty table, see
`hash-map' for creating tables that have additional
metadata attached for this test to work.
@@ -220,14 +220,14 @@ Empty tables created with `hash-map' will pass the test:
(not= k 1))))))
(fn* core.vector?
- "Check whether `tbl` is an sequential table.
+ "Check whether `tbl' is an sequential table.
Non empty sequential tables are tested for two things:
-- `next` returns the key-value pair,
-- key, that is returned by the `next` is equal to `1`.
+- `next' returns the key-value pair,
+- key, that is returned by the `next' is equal to `1`.
Empty tables can't be analyzed with this method, and `vector?' will
-always return `false`. If you need this test pass for empty table,
+always return `false'. If you need this test pass for empty table,
see `vector' for creating tables that have additional
metadata attached for this test to work.
@@ -262,10 +262,10 @@ Empty tables created with `vector' will pass the test:
(and (not= k nil) (= k 1))))))
(fn* core.multifn?
- "Test if `mf` is an instance of `multifn`.
+ "Test if `mf' is an instance of `multifn'.
-`multifn` is a special kind of table, created with `defmulti` macros
-from `macros.fnl`."
+`multifn' is a special kind of table, created with `defmulti' macros
+from `macros.fnl'."
[mf]
(= (. (or (getmetatable mf) {}) :cljlib/type) :multifn))
@@ -278,77 +278,77 @@ from `macros.fnl`."
_ false))
(fn* core.nil?
- "Test if `x` is nil."
+ "Test if `x' is nil."
([] true)
([x] (= x nil)))
(fn* core.zero?
- "Test if `x` is equal to zero."
+ "Test if `x' is equal to zero."
[x]
(= x 0))
(fn* core.pos?
- "Test if `x` is greater than zero."
+ "Test if `x' is greater than zero."
[x]
(> x 0))
(fn* core.neg?
- "Test if `x` is less than zero."
+ "Test if `x' is less than zero."
[x]
(< x 0))
(fn* core.even?
- "Test if `x` is even."
+ "Test if `x' is even."
[x]
(= (% x 2) 0))
(fn* core.odd?
- "Test if `x` is odd."
+ "Test if `x' is odd."
[x]
(not (even? x)))
(fn* core.string?
- "Test if `x` is a string."
+ "Test if `x' is a string."
[x]
(= (type x) :string))
(fn* core.boolean?
- "Test if `x` is a Boolean"
+ "Test if `x' is a Boolean"
[x]
(= (type x) :boolean))
(fn* core.true?
- "Test if `x` is `true`"
+ "Test if `x' is `true'"
[x]
(= x true))
(fn* core.false?
- "Test if `x` is `false`"
+ "Test if `x' is `false'"
[x]
(= x false))
(fn* core.int?
- "Test if `x` is a number without floating point data.
+ "Test if `x' is a number without floating point data.
-Number is rounded with `math.floor` and compared with original number."
+Number is rounded with `math.floor' and compared with original number."
[x]
(and (= (type x) :number)
(= x (math.floor x))))
(fn* core.pos-int?
- "Test if `x` is a positive integer."
+ "Test if `x' is a positive integer."
[x]
(and (int? x)
(pos? x)))
(fn* core.neg-int?
- "Test if `x` is a negative integer."
+ "Test if `x' is a negative integer."
[x]
(and (int? x)
(neg? x)))
(fn* core.double?
- "Test if `x` is a number with floating point data."
+ "Test if `x' is a number with floating point data."
[x]
(and (= (type x) :number)
(not= x (math.floor x))))
@@ -362,7 +362,7 @@ Number is rounded with `math.floor` and compared with original number."
_ (error "empty?: unsupported collection")))
(fn* core.not-empty
- "If `x` is empty, returns `nil`, otherwise `x`."
+ "If `x' is empty, returns `nil', otherwise `x'."
[x]
(if (not (empty? x))
x))
@@ -378,7 +378,7 @@ Number is rounded with `math.floor` and compared with original number."
(fn* core.vector
"Constructs sequential table out of it's arguments.
-Sets additional metadata for function `vector?` to work.
+Sets additional metadata for function `vector?' to work.
# Examples
@@ -393,10 +393,10 @@ Sets additional metadata for function `vector?` to work.
"Create sequential table.
Transforms original table to sequential table of key value pairs
-stored as sequential tables in linear time. If `col` is an
+stored as sequential tables in linear time. If `col' is an
associative table, returns sequential table of vectors with key and
-value. If `col` is sequential table, returns its shallow copy. If
-`col` is string, return sequential table of its codepoints.
+value. If `col' is sequential table, returns its shallow copy. If
+`col' is string, return sequential table of its codepoints.
# Examples
Sequential tables remain as is:
@@ -414,7 +414,7 @@ Associative tables are transformed to format like this `[[key1 value1]
;; [[:b 2] [:a 1] [:c 3]]
```
-See `into` macros for transforming this back to associative table.
+See `into' macros for transforming this back to associative table.
Additionally you can use `conj' and `apply' with
`hash-map':
@@ -450,7 +450,7 @@ Additionally you can use `conj' and `apply' with
_ (error (.. "expected table, string or nil, got " (type col)) 2))))
(fn* core.kvseq
- "Transforms any table `col` to key-value sequence."
+ "Transforms any table `col' to key-value sequence."
[col]
(let [res (empty [])]
(match (type col)
@@ -473,21 +473,21 @@ Additionally you can use `conj' and `apply' with
_ (error (.. "expected table, string or nil, got " (type col)) 2))))
(fn* core.first
- "Return first element of a table. Calls `seq` on its argument."
+ "Return first element of a table. Calls `seq' on its argument."
[col]
(when-some [col (seq col)]
(. col 1)))
(fn* core.rest
"Returns table of all elements of a table but the first one. Calls
- `seq` on its argument."
+ `seq' on its argument."
[col]
(if-some [col (seq col)]
(vector (_unpack col 2))
(empty [])))
(fn* core.last
- "Returns the last element of a table. Calls `seq` on its argument."
+ "Returns the last element of a table. Calls `seq' on its argument."
[col]
(when-some [col (seq col)]
(var (i v) (next col))
@@ -499,7 +499,7 @@ Additionally you can use `conj' and `apply' with
(fn* core.butlast
"Returns everything but the last element of a table as a new
- table. Calls `seq` on its argument."
+ table. Calls `seq' on its argument."
[col]
(when-some [col (seq col)]
(table.remove col (length col))
@@ -507,15 +507,15 @@ Additionally you can use `conj' and `apply' with
col)))
(fn* core.conj
- "Insert `x` as a last element of a table `tbl`.
+ "Insert `x' as a last element of a table `tbl'.
-If `tbl` is a sequential table or empty table, inserts `x` and
-optional `xs` as final element in the table.
+If `tbl' is a sequential table or empty table, inserts `x' and
+optional `xs' as final element in the table.
-If `tbl` is an associative table, that satisfies `map?` test,
+If `tbl' is an associative table, that satisfies `map?' test,
insert `[key value]` pair into the table.
-Mutates `tbl`.
+Mutates `tbl'.
# Examples
Adding to sequential tables:
@@ -557,7 +557,7 @@ See `hash-map' for creating empty associative tables."
(apply conj (conj tbl x) xs)))
(fn* core.disj
- "Remove key `k` from set `s`."
+ "Remove key `k' from set `s'."
([s] (if (set? s) s
(error "expected either hash-set or ordered-set as first argument" 2)))
([s k]
@@ -568,13 +568,13 @@ See `hash-map' for creating empty associative tables."
(apply disj (disj s k) ks)))
(fn consj [...]
- "Like conj but joins at the front. Modifies `tbl`."
+ "Like conj but joins at the front. Modifies `tbl'."
(let [[tbl x & xs] [...]]
(if (nil? x) tbl
(consj (doto tbl (insert 1 x)) (_unpack xs)))))
(fn* core.cons
- "Insert `x` to `tbl` at the front. Calls `seq' on `tbl`."
+ "Insert `x' to `tbl' at the front. Calls `seq' on `tbl'."
[x tbl]
(if-some [x x]
(doto (or (seq tbl) (empty []))
@@ -594,9 +594,9 @@ See `hash-map' for creating empty associative tables."
(apply concat (concat x y) xs)))
(fn* core.reduce
- "Reduce collection `col` using function `f` and optional initial value `val`.
+ "Reduce collection `col' using function `f' and optional initial value `val'.
-`f` should be a function of 2 arguments. If val is not supplied,
+`f' should be a function of 2 arguments. If val is not supplied,
returns the result of applying f to the first 2 items in coll, then
applying f to that result and the 3rd item, etc. If coll contains no
items, f must accept no arguments as well, and reduce returns the
@@ -604,7 +604,7 @@ result of calling f with no arguments. If coll has only 1 item, it is
returned and f is not called. If val is supplied, returns the result
of applying f to val and the first item in coll, then applying f to
that result and the 2nd item, etc. If coll contains no items, returns
-val and f is not called. Calls `seq` on `col`.
+val and f is not called. Calls `seq' on `col'.
Early termination is possible with the use of `reduced'
function.
@@ -641,7 +641,7 @@ Reduce sequence of numbers with `add'
(reduce f (f val x) xs)))))))
(fn* core.reduced
- "Wraps `x` in such a way so `reduce' will terminate early
+ "Wraps `x' in such a way so `reduce' will terminate early
with this value.
# Examples
@@ -671,12 +671,12 @@ valid number, but we've terminated right before we've reached it."
:val x}}))
(fn* core.reduce-kv
- "Reduces an associative table using function `f` and initial value `val`.
+ "Reduces an associative table using function `f' and initial value `val'.
-`f` should be a function of 3 arguments. Returns the result of
-applying `f` to `val`, the first key and the first value in `tbl`,
-then applying `f` to that result and the 2nd key and value, etc. If
-`tbl` contains no entries, returns `val` and `f` is not called. Note
+`f' should be a function of 3 arguments. Returns the result of
+applying `f' to `val', the first key and the first value in `tbl',
+then applying `f' to that result and the 2nd key and value, etc. If
+`tbl' contains no entries, returns `val' and `f' is not called. Note
that reduce-kv is supported on sequential tables and strings, where
the keys will be the ordinals.
@@ -696,7 +696,7 @@ Reduce associative table by adding values from all keys:
;; => 8
```
-Reduce table by adding values from keys that start with letter `a`:
+Reduce table by adding values from keys that start with letter `a':
``` fennel
(local t {:a1 1
@@ -720,17 +720,17 @@ Reduce table by adding values from keys that start with letter `a`:
res)
(fn* core.mapv
- "Maps function `f` over one or more collections.
+ "Maps function `f' over one or more collections.
-Accepts arbitrary amount of collections, calls `seq` on each of it.
-Function `f` must take the same amount of arguments as the amount of
-tables, passed to `mapv`. Applies `f` over first value of each
-table. Then applies `f` to second value of each table. Continues until
+Accepts arbitrary amount of collections, calls `seq' on each of it.
+Function `f' must take the same amount of arguments as the amount of
+tables, passed to `mapv'. Applies `f' over first value of each
+table. Then applies `f' to second value of each table. Continues until
any of the tables is exhausted. All remaining values are
ignored. Returns a sequential table of results.
# Examples
-Map `string.upcase` over the string:
+Map `string.upcase' over the string:
``` fennel
(mapv string.upper \"string\")
@@ -744,7 +744,7 @@ Map `mul' over two tables:
;; => [1 0 -3]
```
-Basic `zipmap` implementation:
+Basic `zipmap' implementation:
``` fennel
(import-macros {: into} :macros)
@@ -801,7 +801,7 @@ Basic `zipmap` implementation:
res)))
(fn* core.filter
- "Returns a sequential table of the items in `col` for which `pred`
+ "Returns a sequential table of the items in `col' for which `pred'
returns logical true."
[pred col]
(if-let [col (seq col)]
@@ -813,25 +813,25 @@ Basic `zipmap` implementation:
(empty [])))
(fn* core.every?
- "Test if every item in `tbl` satisfies the `pred`."
+ "Test if every item in `tbl' satisfies the `pred'."
[pred tbl]
(if (empty? tbl) true
(pred (. tbl 1)) (every? pred [(_unpack tbl 2)])
false))
(fn* core.some
- "Test if any item in `tbl` satisfies the `pred`."
+ "Test if any item in `tbl' satisfies the `pred'."
[pred tbl]
(when-let [tbl (seq tbl)]
(or (pred (. tbl 1)) (some pred [(_unpack tbl 2)]))))
(fn* core.not-any?
- "Test if no item in `tbl` satisfy the `pred`."
+ "Test if no item in `tbl' satisfy the `pred'."
[pred tbl]
(some #(not (pred $)) tbl))
(fn* core.range
- "return range of of numbers from `lower` to `upper` with optional `step`."
+ "return range of of numbers from `lower' to `upper' with optional `step'."
([upper] (range 0 upper 1))
([lower upper] (range lower upper 1))
([lower upper step]
@@ -841,7 +841,7 @@ Basic `zipmap` implementation:
res)))
(fn* core.reverse
- "Returns table with same items as in `tbl` but in reverse order."
+ "Returns table with same items as in `tbl' but in reverse order."
[tbl]
(when-some [tbl (seq tbl)]
(reduce consj (empty []) tbl)))
@@ -856,8 +856,8 @@ Basic `zipmap` implementation:
(var eq nil)
(fn deep-index [tbl key]
- "This function uses the pre-declared `eq`, which we set later on,
-because `eq` requires this function internally. Several other
+ "This function uses the pre-declared `eq', which we set later on,
+because `eq' requires this function internally. Several other
functions also reuse this indexing method, such as sets."
(var res nil)
(each [k v (pairs tbl)]
@@ -914,8 +914,8 @@ functions also reuse this indexing method, such as sets."
(reduce comp (consj fs g f))))
(fn* core.complement
- "Takes a function `f` and returns the function that takes the same
-amount of arguments as `f`, has the same effect, and returns the
+ "Takes a function `f' and returns the function that takes the same
+amount of arguments as `f', has the same effect, and returns the
oppisite truth value."
[f]
(fn*
@@ -925,7 +925,7 @@ oppisite truth value."
([a b & cs] (not (apply f a b cs)))))
(fn* core.constantly
- "Returns a function that takes any number of arguments and returns `x`."
+ "Returns a function that takes any number of arguments and returns `x'."
[x]
(fn [] x))
@@ -956,7 +956,7 @@ use."
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Hash table extras ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(fn* core.assoc
- "Associate key `k` with value `v` in `tbl`."
+ "Associate key `k' with value `v' in `tbl'."
([tbl k v]
(assert (not (nil? k)) "attempt to use nil as key")
(setmetatable
@@ -976,14 +976,14 @@ use."
(setmetatable tbl {:cljlib/type :table})))
(fn* core.hash-map
- "Create associative table from `kvs` represented as sequence of keys
+ "Create associative table from `kvs' represented as sequence of keys
and values"
([] (empty {}))
([& kvs] (apply assoc {} kvs)))
(fn* core.get
- "Get value from the table by accessing it with a `key`.
-Accepts additional `not-found` as a marker to return if value wasn't
+ "Get value from the table by accessing it with a `key'.
+Accepts additional `not-found' as a marker to return if value wasn't
found in the table."
([tbl key] (get tbl key nil))
([tbl key not-found]
@@ -993,7 +993,7 @@ found in the table."
(fn* core.get-in
"Get value from nested set of tables by providing key sequence.
-Accepts additional `not-found` as a marker to return if value wasn't
+Accepts additional `not-found' as a marker to return if value wasn't
found in the table."
([tbl keys] (get-in tbl keys nil))
([tbl keys not-found]
@@ -1022,13 +1022,13 @@ found in the table."
res))
(fn* core.find
- "Returns the map entry for `key`, or `nil` if key not present in `tbl`."
+ "Returns the map entry for `key', or `nil' if key not present in `tbl'."
[tbl key]
(when-some [v (. tbl key)]
[key v]))
(fn* core.dissoc
- "Remove `key` from table `tbl`. Optionally takes more `keys`."
+ "Remove `key' from table `tbl'. Optionally takes more `keys`."
([tbl] tbl)
([tbl key]
(doto tbl (tset key nil)))
@@ -1042,7 +1042,7 @@ found in the table."
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Multimethods ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(fn* core.remove-method
- "Remove method from `multimethod` for given `dispatch-value`."
+ "Remove method from `multimethod' for given `dispatch-value'."
[multimethod dispatch-value]
(if (multifn? multimethod)
(tset multimethod dispatch-value nil)
@@ -1050,7 +1050,7 @@ found in the table."
multimethod)
(fn* core.remove-all-methods
- "Removes all of the methods of `multimethod`"
+ "Removes all of the methods of `multimethod'"
[multimethod]
(if (multifn? multimethod)
(each [k _ (pairs multimethod)]
@@ -1059,7 +1059,7 @@ found in the table."
multimethod)
(fn* core.methods
- "Given a `multimethod`, returns a map of dispatch values -> dispatch fns"
+ "Given a `multimethod', returns a map of dispatch values -> dispatch fns"
[multimethod]
(if (multifn? multimethod)
(let [m {}]
@@ -1069,8 +1069,8 @@ found in the table."
(error (.. (tostring multimethod) " is not a multifn") 2)))
(fn* core.get-method
- "Given a `multimethod` and a `dispatch-value`, returns the dispatch
-`fn` that would apply to that value, or `nil` if none apply and no
+ "Given a `multimethod' and a `dispatch-value', returns the dispatch
+`fn' that would apply to that value, or `nil' if none apply and no
default."
[multimethod dispatch-value]
(if (multifn? multimethod)
@@ -1146,7 +1146,7 @@ Updates order of all items when some key removed from set."
(values k v)))
(fn ordered-set-pairs [Set]
- "Returns stateless `ipairs` iterator for ordered sets."
+ "Returns stateless `ipairs' iterator for ordered sets."
(fn []
(var i 0)
(var iseq nil)
@@ -1159,7 +1159,7 @@ Updates order of all items when some key removed from set."
(values set-next Set nil)))
(fn hash-set-pairs [Set]
- "Returns stateful `ipairs` iterator for hashed sets."
+ "Returns stateful `ipairs' iterator for hashed sets."
(fn []
(fn iter [t k]
(let [v (next t k)]
@@ -1167,7 +1167,7 @@ Updates order of all items when some key removed from set."
(values iter Set nil)))
(fn into-set [Set tbl]
- "Transform `tbl` into `Set`"
+ "Transform `tbl' into `Set`"
(each [_ v (pairs (or (seq tbl) []))]
(conj Set v))
Set)
@@ -1180,15 +1180,15 @@ Updates order of all items when some key removed from set."
Set is a collection of unique elements, which sore purpose is only to
tell you if something is in the set or not.
-`ordered-set` is follows the argument insertion order, unlike sorted
+`ordered-set' is follows the argument insertion order, unlike sorted
sets, which apply some sorting algorithm internally. New items added
at the end of the set. Ordered set supports removal of items via
-`tset` and `disj'. To add element to the ordered set use
-`tset` or `conj'. Both operations modify the set.
+`tset' and `disj'. To add element to the ordered set use
+`tset' or `conj'. Both operations modify the set.
**Note**: Hash set prints as `@set{a b c}`, but this construct is not
supported by the Fennel reader, so you can't create sets with this
-syntax. Use `hash-set` function instead.
+syntax. Use `ordered-set' function instead.
Below are some examples of how to create and manipulate sets.
@@ -1212,7 +1212,7 @@ Duplicate items are not added:
## Check if set contains desired value:
Sets are functions of their keys, so simply calling a set with a
-desired key will either return the key, or `nil`:
+desired key will either return the key, or `nil':
``` fennel
(local oset (ordered-set [:a :b :c] [:c :d :e] :e :f))
@@ -1225,7 +1225,7 @@ desired key will either return the key, or `nil`:
```
## Add items to existing set:
-To add element to the set use `conj' or `tset`
+To add element to the set use `conj' or `tset'
``` fennel
(local oset (ordered-set :a :b :c))
@@ -1234,7 +1234,7 @@ To add element to the set use `conj' or `tset`
```
### Remove items from the set:
-To add element to the set use `disj' or `tset`
+To add element to the set use `disj' or `tset'
``` fennel
(local oset (ordered-set :a :b :c))
@@ -1246,7 +1246,7 @@ oset
```
## Equality semantics
-Both `ordered-set` and `hash-set' implement `__eq` metamethod,
+Both `ordered-set' and `hash-set' implement `__eq` metamethod,
and are compared for having the same keys without particular order and
same size:
@@ -1285,13 +1285,13 @@ tell you if something is in the set or not.
Hash set differs from ordered set in that the keys are do not have any
particular order. New items are added at the arbitrary position by
-using `conj' or `tset` functions, and items can be removed
-with `disj' or `tset` functions. Rest semantics are the same
+using `conj' or `tset' functions, and items can be removed
+with `disj' or `tset' functions. Rest semantics are the same
as for `ordered-set'
**Note**: Hash set prints as `@set{a b c}`, but this construct is not
supported by the Fennel reader, so you can't create sets with this
-syntax. Use `hash-set` function instead."
+syntax. Use `hash-set' function instead."
[& xs]
(let [Set (setmetatable {} {:__index deep-index})
set-pairs (hash-set-pairs Set)]
diff --git a/macros.fnl b/macros.fnl
index 29c1eed..75effd5 100644
--- a/macros.fnl
+++ b/macros.fnl
@@ -28,7 +28,7 @@
(values s false))))
(fn contains? [tbl x]
- ;; Checks if `x` is stored in `tbl` in linear time.
+ ;; Checks if `x' is stored in `tbl' in linear time.
(var res false)
(each [i v (ipairs tbl)]
(if (= v x)
@@ -37,8 +37,8 @@
res)
(fn check-two-binding-vec [bindings]
- ;; Test if `bindings` is a `sequence` that holds two forms, first of
- ;; which is a `sym`, `table` or `sequence`.
+ ;; Test if `bindings' is a `sequence' that holds two forms, first of
+ ;; which is a `sym', `table' or `sequence'.
(and (assert-compile (sequence? bindings)
"expected binding table" [])
(assert-compile (= (length bindings) 2)
@@ -57,7 +57,7 @@
;;;;;;;;;;;;;;;;;;;;;;;;;; Runtime function builders ;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; TODO: This code should be shared with `init.fnl`
+;; TODO: This code should be shared with `init.fnl'
(fn eq-fn []
;; Returns recursive equality function.
@@ -160,8 +160,8 @@
(fn when-meta [...]
"Wrapper that compiles away if metadata support was not enabled.
What this effectively means, is that everything that is wrapped with
-this macro and its `body` will disappear from the resulting Lua code
-if metadata is not enabled when compiling with `fennel --compile`
+this macro and its `body' will disappear from the resulting Lua code
+if metadata is not enabled when compiling with `fennel --compile'
without `--metadata` switch."
(when meta-enabled
`(do ,...)))
@@ -169,8 +169,8 @@ without `--metadata` switch."
(attach-meta when-meta {:fnl/arglist ["[& body]"]})
(fn meta [value]
- "Get `value` metadata. If value has no metadata, or metadata
-feature is not enabled returns `nil`.
+ "Get `value' metadata. If value has no metadata, or metadata
+feature is not enabled returns `nil'.
# Example
@@ -193,18 +193,18 @@ used. This, for example, may cause documentation collision, when
you've set some variable holding a number value to have certain
docstring, and later you've defined another variable with the same
value, but different docstring. While this isn't a major breakage, it
-may confuse if someone will explore your code in the REPL with `doc`.
+may confuse if someone will explore your code in the REPL with `doc'.
-Lastly, note that prior to Fennel 0.7.1 `import-macros` wasn't
+Lastly, note that prior to Fennel 0.7.1 `import-macros' wasn't
respecting `--metadata` switch. So if you're using Fennel < 0.7.1
-this stuff will only work if you use `require-macros` instead of
-`import-macros`."
+this stuff will only work if you use `require-macros' instead of
+`import-macros'."
(when-meta
`(let [(res# fennel#) (pcall require :fennel)]
(if res# (. fennel#.metadata ,value)))))
(fn with-meta [value meta]
- "Attach `meta` to a `value`. When metadata feature is not enabled,
+ "Attach `meta' to a `value'. When metadata feature is not enabled,
returns the value without additional metadata.
``` fennel
@@ -276,7 +276,7 @@ returns the value without additional metadata.
arglist)))
(fn has-amp? [args]
- ;; Check if arglist has `&` and return its position of `false`. Performs
+ ;; Check if arglist has `&` and return its position of `false'. Performs
;; additional checks for `&` and `...` usage in arglist.
(var res false)
(each [i s (ipairs args)]
@@ -326,21 +326,21 @@ returns the value without additional metadata.
prev))
(fn arity-dispatcher [len fixed amp-body name]
- ;; Forms an `if` expression with all fixed arities first, then `&` arity,
+ ;; Forms an `if' expression with all fixed arities first, then `&` arity,
;; if present, and default error message as last arity.
;;
- ;; `len` is a symbol, that represents the length of the current argument
+ ;; `len' is a symbol, that represents the length of the current argument
;; list, and is computed at runtime.
;;
- ;; `fixed` is a table of arities with fixed amount of arguments. These
- ;; are put in this `if` as: `(= len fixed-len)`, where `fixed-len` is the
- ;; length of current arity arglist, computed with `gen-arity`.
+ ;; `fixed' is a table of arities with fixed amount of arguments. These
+ ;; are put in this `if' as: `(= len fixed-len)`, where `fixed-len' is the
+ ;; length of current arity arglist, computed with `gen-arity'.
;;
- ;; `amp-body` stores size of fixed part of arglist, that is, everything up
- ;; until `&`, and the body itself. When `amp-body` provided, the `(>= len
- ;; more-len)` is added to the resulting `if` expression.
+ ;; `amp-body' stores size of fixed part of arglist, that is, everything up
+ ;; until `&`, and the body itself. When `amp-body' provided, the `(>= len
+ ;; more-len)` is added to the resulting `if' expression.
;;
- ;; Lastly the catchall branch is added to `if` expression, which ensures
+ ;; Lastly the catchall branch is added to `if' expression, which ensures
;; that only valid amount of arguments were passed to function, which are
;; defined by previous branches.
(let [bodies '(if)
@@ -417,10 +417,10 @@ returns the value without additional metadata.
(fn fn* [name doc? ...]
"Create (anonymous) function of fixed arity.
-Accepts optional `name` and `docstring?` as first two arguments,
+Accepts optional `name' and `docstring?' as first two arguments,
followed by single or multiple arity bodies defined as lists. Each
-list starts with `arglist*` vector, which supports destructuring, and
-is followed by `body*` wrapped in implicit `do`.
+list starts with `arglist*' vector, which supports destructuring, and
+is followed by `body*' wrapped in implicit `do'.
# Examples
Named function of fixed arity 2:
@@ -456,17 +456,17 @@ argument list:
``` fennel
(fn* cube
- \"raise `x` to power of 3\"
+ \"raise `x' to power of 3\"
[x]
(^ x 3))
(fn* greet
- \"greet a `person`, optionally specifying default `greeting`.\"
+ \"greet a `person', optionally specifying default `greeting'.\"
([person] (print (.. \"Hello, \" person \"!\")))
([greeting person] (print (.. greeting \", \" person \"!\"))))
```
-Argument lists follow the same destruction rules as per `let`.
+Argument lists follow the same destruction rules as per `let'.
Variadic arguments with `...` are not supported use `& rest` instead.
Note that only one arity with `&` is supported.
@@ -480,12 +480,12 @@ This roughly means, that instead of writing this:
``` fennel
(local ns {})
-(fn f [x] ;; we have to define `f` without `ns`
- (if (> x 0) (f (- x 1)))) ;; because we're going to use it in `g`
+(fn f [x] ;; we have to define `f' without `ns'
+ (if (> x 0) (f (- x 1)))) ;; because we're going to use it in `g'
(set ns.f f)
-(fn ns.g [x] (f (* x 100))) ;; `g` can be defined as `ns.g` as it is only exported
+(fn ns.g [x] (f (* x 100))) ;; `g' can be defined as `ns.g' as it is only exported
ns
```
@@ -498,16 +498,16 @@ It is possible to write:
(fn* ns.f [x]
(if (> x 0) (f (- x 1))))
-(fn* ns.g [x] (f (* x 100))) ;; we can use `f` here no problem
+(fn* ns.g [x] (f (* x 100))) ;; we can use `f' here no problem
ns
```
-It is still possible to call `f` and `g` in current scope without `ns`
-part, so functions can be reused inside the module, and `ns` will hold
+It is still possible to call `f' and `g' in current scope without `ns'
+part, so functions can be reused inside the module, and `ns' will hold
both functions, so it can be exported from the module.
-Note that `fn` will not create the `ns` for you, hence this is just a
+Note that `fn' will not create the `ns' for you, hence this is just a
syntax sugar. Functions deeply nested in namespaces require exising
namespace tables:
@@ -518,7 +518,7 @@ namespace tables:
(fn* ns.strings.join
([s1 s2] (.. s1 s2))
([s1 s2 & strings]
- (join (join s1 s2) ((or table.unpack _G.unpack) strings)))) ;; call `join` resolves to ns.strings.join
+ (join (join s1 s2) ((or table.unpack _G.unpack) strings)))) ;; call `join' resolves to ns.strings.join
(fn* ns.tables.join
([t1 t2]
@@ -527,7 +527,7 @@ namespace tables:
(each [_ v (ipairs t2)] (table.insert res v))
res))
([t1 t2 & tables]
- (join (join t1 t2) ((or table.unpack _G.unpack) tables)))) ;; call to `join` resolves to ns.tables.join
+ (join (join t1 t2) ((or table.unpack _G.unpack) tables)))) ;; call to `join' resolves to ns.tables.join
(assert-eq (ns.strings.join \"a\" \"b\" \"c\") \"abc\")
@@ -537,9 +537,9 @@ namespace tables:
[])
```
-Note that this creates a collision and local `join` overrides `join`
-from `ns.strings`, so the latter must be fully qualified
-`ns.strings.join` when called outside of the function."
+Note that this creates a collision and local `join' overrides `join'
+from `ns.strings', so the latter must be fully qualified
+`ns.strings.join' when called outside of the function."
(assert-compile (not (string? name)) "fn* expects symbol, vector, or list as first argument" name)
(let [docstring (if (string? doc?) doc? nil)
(name-wo-namespace namespaced?) (multisym->sym name)
@@ -569,17 +569,17 @@ from `ns.strings`, so the latter must be fully qualified
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; let variants ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; Fennel indeed has more advanced macro `match` which can be used in
+;; Fennel indeed has more advanced macro `match' which can be used in
;; place of any of the following macros, however it is sometimes more
-;; convenient to convey intentions by explicitly saying `when-some`
+;; convenient to convey intentions by explicitly saying `when-some'
;; implying that we're interested in non-nil value and only single branch
-;; of execution. The `match` macro on the other hand does not convey
+;; of execution. The `match' macro on the other hand does not convey
;; such intention
(fn if-let [...]
- "If `binding` is set by `test` to logical true, evaluates `then-branch`
+ "If `binding' is set by `test' to logical true, evaluates `then-branch'
with binding-form bound to the value of test, if not, yields
-`else-branch`."
+`else-branch'."
(let [[bindings then else] (match (select :# ...)
2 [...]
3 [...]
@@ -596,8 +596,8 @@ with binding-form bound to the value of test, if not, yields
(fn when-let [...]
- "If `binding` was bound by `test` to logical true, evaluates `body` in
-implicit `do`."
+ "If `binding' was bound by `test' to logical true, evaluates `body' in
+implicit `do'."
(let [[bindings & body] (if (> (select :# ...) 0) [...]
(error "wrong argument amount for when-let" 2))]
(check-two-binding-vec bindings)
@@ -611,8 +611,8 @@ implicit `do`."
(fn if-some [...]
- "If `test` is non-`nil`, evaluates `then-branch` with `binding`-form bound
-to the value of test, if not, yields `else-branch`."
+ "If `test' is non-`nil', evaluates `then-branch' with `binding'-form bound
+to the value of test, if not, yields `else-branch'."
(let [[bindings then else] (match (select :# ...)
2 [...]
3 [...]
@@ -629,8 +629,8 @@ to the value of test, if not, yields `else-branch`."
(fn when-some [...]
- "If `test` sets `binding` to non-`nil`, evaluates `body` in implicit
-`do`."
+ "If `test' sets `binding' to non-`nil', evaluates `body' in implicit
+`do'."
(let [[bindings & body] (if (> (select :# ...) 0) [...]
(error "wrong argument amount for when-some" 2))]
(check-two-binding-vec bindings)
@@ -651,11 +651,11 @@ to the value of test, if not, yields `else-branch`."
:else))
(fn into [to from]
- "Transform table `from` into another table `to`. Mutates first table.
+ "Transform table `from' into another table `to'. Mutates first table.
Transformation happens in runtime, but type deduction happens in
compile time if possible. This means, that if literal values passed
-to `into` this will have different effects for associative tables and
+to `into' this will have different effects for associative tables and
vectors:
``` fennel
@@ -678,7 +678,7 @@ will not work for empty tables:
(assert-eq (into empty-table {:a 1}) [[:a 1]])
``` fennel
-If table is empty, `into` defaults to sequential table, because it
+If table is empty, `into' defaults to sequential table, because it
allows safe conversion from both sequential and associative tables.
Type for non empty tables hidden in variables can be deduced at
@@ -691,8 +691,8 @@ runtime, and this works as expected:
(assert-eq (into t2 {:a 1}) {:a 1 :c 3})
```
-`cljlib.fnl` module provides two additional functions `vector` and
-`hash-map`, that can create empty tables, which can be distinguished
+`cljlib.fnl' module provides two additional functions `vector' and
+`hash-map', that can create empty tables, which can be distinguished
at runtime:
``` fennel
@@ -796,11 +796,11 @@ at runtime:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; empty ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(fn empty [x]
- "Return empty table of the same kind as input table `x`, with
+ "Return empty table of the same kind as input table `x', with
additional metadata indicating its type.
# Example
-Creating a generic `map` function, that will work on any table type,
+Creating a generic `map' function, that will work on any table type,
and return result of the same type:
``` fennel
@@ -849,7 +849,7 @@ See `into' for more info on how conversion is done."
(let [options (seq->table options)]
(if (in-scope? name)
`nil
- `(local ,name
+ '(local ,name
(setmetatable
,(with-meta {} {:fnl/docstring docstring})
{:__index
@@ -879,14 +879,14 @@ See `into' for more info on how conversion is done."
:cljlib/type :multifn}))))))
(attach-meta defmulti {:fnl/arglist [:name :docstring? :dispatch-fn :options*]
- :fnl/docstring "Create multifunction `name` with runtime dispatching based on results
-from `dispatch-fn`. Returns a proxy table with `__call` metamethod,
-that calls `dispatch-fn` on its arguments. Amount of arguments
-passed, should be the same as accepted by `dispatch-fn`. Looks for
-multimethod based on result from `dispatch-fn`.
-
-Accepts optional `docstring?`, and `options*` arguments, where
-`options*` is a sequence of key value pairs representing additional
+ :fnl/docstring "Create multifunction `name' with runtime dispatching based on results
+from `dispatch-fn'. Returns a proxy table with `__call` metamethod,
+that calls `dispatch-fn' on its arguments. Amount of arguments
+passed, should be the same as accepted by `dispatch-fn'. Looks for
+multimethod based on result from `dispatch-fn'.
+
+Accepts optional `docstring?', and `options*' arguments, where
+`options*' is a sequence of key value pairs representing additional
attributes. Supported options:
`:default` - the default dispatch value, defaults to `:default`.
@@ -901,8 +901,8 @@ By default, multifunction has no multimethods, see
(attach-meta defmethod {:fnl/arglist [:multi-fn :dispatch-value :fnspec]
:fnl/docstring "Attach new method to multi-function dispatch value. accepts the
-`multi-fn` as its first argument, the `dispatch-value` as second, and
-`fnspec` - a function tail starting from argument list, followed by
+`multi-fn' as its first argument, the `dispatch-value' as second, and
+`fnspec' - a function tail starting from argument list, followed by
function body as in `fn*'.
# Examples
@@ -910,7 +910,7 @@ Here are some examples how multimethods can be used.
## Factorial example
Key idea here is that multimethods can call itself with different
-values, and will dispatch correctly. Here, `fac` recursively calls
+values, and will dispatch correctly. Here, `fac' recursively calls
itself with less and less number until it reaches `0` and dispatches
to another multimethod:
@@ -940,7 +940,7 @@ Multi-arity function tails are also supported:
Calling `(foo 10)` will print `\"I've knew I'll get 10\"`, and calling
`(foo 10 20)` will print `\"I've knew I'll get both 10 and 20\"`.
-However, calling `foo` with any other numbers will default either to
+However, calling `foo' with any other numbers will default either to
`\"Umm, got x\"` message, when called with single value, and `\"Umm, got
both x and y\"` when calling with two values.
@@ -975,44 +975,44 @@ function, that uses if statement and branches on the type, however one
of the additional features of multimethods, is that separate libraries
can extend such multimethod by adding additional claues to it without
needing to patch the source of the function. For example later on
-support for userdata or coroutines can be added to `to-lua-str`
+support for userdata or coroutines can be added to `to-lua-str'
function as a separate multimethods for respective types."})
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; def and defonce ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(fn def [...]
- "Wrapper around `local` which can declare variables inside namespace,
-and as local `name` at the same time similarly to
-`fn*'. Accepts optional `attr-map?` which can contain a
+ "Wrapper around `local' which can declare variables inside namespace,
+and as local `name' at the same time similarly to
+`fn*'. Accepts optional `attr-map?' which can contain a
docstring, and whether variable should be mutable or not. Sets
-variable to the result of `expr`.
+variable to the result of `expr'.
``` fennel
(def ns {})
-(def a 10) ;; binds `a` to `10`
+(def a 10) ;; binds `a' to `10`
(assert-eq a 10)
-(def ns.b 20) ;; binds `ns.b` and `b` to `20`
+(def ns.b 20) ;; binds `ns.b' and `b' to `20`
(assert-eq b 20)
(assert-eq ns.b 20)
```
-`a` is a `local`, and both `ns.b` and `b` refer to the same value.
+`a' is a `local', and both `ns.b' and `b' refer to the same value.
Additionally metadata can be attached to values, by providing
attribute map or keyword as first parameter. Only one keyword is
supported, which is `:mutable`, which allows mutating variable with
-`set` later on:
+`set' later on:
``` fennel
;; Bad, will override existing documentation for 299792458 (if any)
(def {:doc \"speed of light in m/s\"} c 299792458)
(def :mutable address \"Lua St.\") ;; same as (def {:mutable true} address \"Lua St.\")
-(set address \"Lisp St.\") ;; can mutate `address`
+(set address \"Lisp St.\") ;; can mutate `address'
```
However, attaching documentation metadata to anything other than
@@ -1039,9 +1039,9 @@ description."
(attach-meta def {:fnl/arglist [:attr-map? :name :expr]})
(fn defonce [...]
- "Works the same as `def', but ensures that later `defonce`
-calls will not override existing bindings. Accepts same `attr-map?` as
-`def`, and sets `name` to the result of `expr`:
+ "Works the same as `def', but ensures that later `defonce'
+calls will not override existing bindings. Accepts same `attr-map?' as
+`def', and sets `name' to the result of `expr':
``` fennel
(defonce a 10)
@@ -1070,10 +1070,10 @@ calls will not override existing bindings. Accepts same `attr-map?` as
(= (tostring fun) :finally))
(fn add-finally [finally form]
- "Stores `form` as body of `finally`, which will be injected into
-`match` branches at places appropriate for it to run.
+ "Stores `form' as body of `finally', which will be injected into
+`match' branches at places appropriate for it to run.
-Checks if there already was `finally` clause met, which can be only
+Checks if there already was `finally' clause met, which can be only
one."
(assert-compile (= (length finally) 0)
"Only one finally clause can exist in try expression"
@@ -1081,17 +1081,17 @@ one."
(table.insert finally (list 'do ((or table.unpack _G.unpack) form 2))))
(fn add-catch [finally catches form]
- "Appends `catch` body to a sequence of catch bodies that will later
-be used in `make-catch-clauses` to produce AST.
+ "Appends `catch' body to a sequence of catch bodies that will later
+be used in `make-catch-clauses' to produce AST.
-Checks if there already was `finally` clause met."
+Checks if there already was `finally' clause met."
(assert-compile (= (length finally) 0)
"finally clause must be last in try expression"
[])
(table.insert catches (list 'do ((or table.unpack _G.unpack) form 2))))
(fn make-catch-clauses [catches finally]
- "Generates AST of error branches for `match` macro."
+ "Generates AST of error branches for `match' macro."
(let [clauses []]
(var add-catchall? true)
(each [_ [_ binding-or-val & body] (ipairs catches)]
@@ -1109,7 +1109,7 @@ Checks if there already was `finally` clause met."
((or table.unpack _G.unpack) clauses)))
(fn add-to-try [finally catches try form]
- "Append form to the try body. There must be no `catch` of `finally`
+ "Append form to the try body. There must be no `catch' of `finally'
clauses when we push body epression."
(assert-compile (and (= (length finally) 0)
(= (length catches) 0))
@@ -1133,26 +1133,26 @@ clauses when we push body epression."
(attach-meta try {:fnl/arglist [:body* :catch-clause* :finally-clause?]
:fnl/docstring "General purpose try/catch/finally macro.
-Wraps its body in `pcall` and checks the return value with `match`
+Wraps its body in `pcall' and checks the return value with `match'
macro.
Catch clause is written either as `(catch symbol body*)`, thus acting
as catch-all, or `(catch value body*)` for catching specific errors.
-It is possible to have several `catch` clauses. If no `catch` clauses
-specified, an implicit catch-all clause is created. `body*`, and
-inner expressions of `catch-clause*`, and `finally-clause?` are
-wrapped in implicit `do`.
+It is possible to have several `catch' clauses. If no `catch' clauses
+specified, an implicit catch-all clause is created. `body*', and
+inner expressions of `catch-clause*', and `finally-clause?' are
+wrapped in implicit `do'.
Finally clause is optional, and written as (finally body*). If
-present, it must be the last clause in the `try` form, and the only
-`finally` clause. Note that `finally` clause is for side effects
-only, and runs either after succesful run of `try` body, or after any
-`catch` clause body, before returning the result. If no `catch`
-clause is provided `finally` runs in implicit catch-all clause, and
-trows error to upper scope using `error` function.
-
-To throw error from `try` to catch it with `catch` clause use `error`
-or `assert` functions.
+present, it must be the last clause in the `try' form, and the only
+`finally' clause. Note that `finally' clause is for side effects
+only, and runs either after succesful run of `try' body, or after any
+`catch' clause body, before returning the result. If no `catch'
+clause is provided `finally' runs in implicit catch-all clause, and
+trows error to upper scope using `error' function.
+
+To throw error from `try' to catch it with `catch' clause use `error'
+or `assert' functions.
# Examples
Catch all errors, ignore those and return fallback value:
diff --git a/tests/test.fnl b/tests/test.fnl
index 8541036..71b89af 100644
--- a/tests/test.fnl
+++ b/tests/test.fnl
@@ -35,8 +35,8 @@ the tables uses tables as keys."
(fn test.assert-eq
[expr1 expr2 msg]
- "Like `assert`, except compares results of `expr1` and `expr2` for equality.
-Generates formatted message if `msg` is not set to other message.
+ "Like `assert', except compares results of `expr1' and `expr2' for equality.
+Generates formatted message if `msg' is not set to other message.
# Example
Compare two expressions:
@@ -72,9 +72,9 @@ Deep compare values:
(fn test.assert-ne
[expr1 expr2 msg]
- "Assert for unequality. Like `assert`, except compares results of
-`expr1` and `expr2` for equality. Generates formatted message if
-`msg` is not set to other message. Same as `assert-eq'."
+ "Assert for unequality. Like `assert', except compares results of
+`expr1' and `expr2' for equality. Generates formatted message if
+`msg' is not set to other message. Same as `assert-eq'."
`(let [left# ,expr1
right# ,expr2
eq# ,(eq-fn)
@@ -91,8 +91,8 @@ Deep compare values:
(fn test.assert-is
[expr msg]
- "Assert `expr` for truth. Same as inbuilt `assert`, except generates more
- verbose message if `msg` is not set.
+ "Assert `expr' for truth. Same as inbuilt `assert', except generates more
+ verbose message if `msg' is not set.
``` fennel
;; (assert-is (= 1 2 3))
@@ -109,8 +109,8 @@ Deep compare values:
(fn test.assert-not
[expr msg]
- "Assert `expr` for not truth. Generates more verbose message if
- `msg` is not set. Works the same as `assert-is'."
+ "Assert `expr' for not truth. Generates more verbose message if
+ `msg' is not set. Works the same as `assert-is'."
`(let [(suc# res#) (pcall #(not ,expr))]
(if suc#
(assert res#
@@ -122,12 +122,12 @@ Deep compare values:
(fn test.deftest
[name ...]
- "Simple way of grouping tests with `name`."
+ "Simple way of grouping tests with `name'."
`(do ,...))
(fn test.testing
[description ...]
- "Print test `description` and run it."
+ "Print test `description' and run it."
`(do (io.stdout:write (.. "testing: " ,description "\n"))
,...))