Skip to content

Commit 5c958f3

Browse files
committed
update functions-and-recursion.md
1 parent 67cdb69 commit 5c958f3

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

content/documentation/functions-and-recursion.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,28 @@ Each global function can take an optional doc comment and attribute map.
8383
"adds value a and b"
8484
[a b]
8585
(+ a b))
86+
```
87+
88+
### Private functions
89+
90+
Private functions are not exported from the namespace and cannot be accessed from other namespaces. You can create private functions in two ways:
8691

92+
1. Using the `{:private true}` attribute map
93+
2. Using the `defn-` shorthand
94+
95+
```phel
8796
(defn my-private-add-function
88-
"adds value a and b"
8997
{:private true}
9098
[a b]
9199
(+ a b))
100+
101+
(defn- my-private-add-function
102+
[a b]
103+
(+ a b))
92104
```
93105

106+
Both approaches are equivalent, but `defn-` provides a more concise syntax for defining private functions.
107+
94108
## Recursion
95109

96110
Similar to `loop`, functions can be made recursive using `recur`.

0 commit comments

Comments
 (0)