Skip to content

Commit f23513a

Browse files
authored
Merge pull request #122 from jasalt/master
doc: add example of aliasing core namespace
2 parents 84a21c8 + f095aa3 commit f23513a

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

content/documentation/namespaces.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,17 @@ To prevent name collision from other modules in different namespaces, aliases ca
5353
(:require hello-world\util :as utilities))
5454
```
5555

56+
When names collide, names from different namespaces remain available by prefixing them with a namespace identifier (such as `phel\core`). However, care should be taken when referring to names before redefining them, as the names retain their values from the original namespaces before the redefinition.
57+
58+
```phel
59+
(ns hello-world\http-client)
60+
61+
(defn get [uri]
62+
{:status 200 :body "Hello World" :headers {}})
63+
64+
(phel\core/get (get "https://example.com") :status) # Evaluates to 200
65+
```
66+
5667
Additionally, it is possible to refer symbols of other modules in the current namespace by using `:refer` keyword.
5768

5869
```phel

0 commit comments

Comments
 (0)