From f095aa391ad89375a487d9107e88710495e0e2a1 Mon Sep 17 00:00:00 2001 From: Jarkko Saltiola Date: Wed, 20 Aug 2025 14:12:53 +0300 Subject: [PATCH] doc: add example of aliasing core namespace --- content/documentation/namespaces.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/content/documentation/namespaces.md b/content/documentation/namespaces.md index 6b08d4c..65b4b06 100644 --- a/content/documentation/namespaces.md +++ b/content/documentation/namespaces.md @@ -53,6 +53,17 @@ To prevent name collision from other modules in different namespaces, aliases ca (:require hello-world\util :as utilities)) ``` +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. + +```phel +(ns hello-world\http-client) + +(defn get [uri] + {:status 200 :body "Hello World" :headers {}}) + +(phel\core/get (get "https://example.com") :status) # Evaluates to 200 +``` + Additionally, it is possible to refer symbols of other modules in the current namespace by using `:refer` keyword. ```phel