practicalli / practicalli/practicalli.github.io

Article: How to understand a Clojure function

Open
#19 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Makefile
Stars
7
Forks
1
PR merge metrics
No merged PRs in 30d

Description

When learning how to develop with Clojure, an important aspect is to understand what functions already exist and how to use those functions

Finding functions

apropos
clojure cli find function ?

Read the function doc-string

The doc-string should describe the function arguments and hopefully give some indication of the types of values that the function works with

doc-strings for clojure.core functions tend to be on the terse side of things and may not immediately be understood.

Look at the examples at clojuredocs.org

Each page on clojuredocs.org includes the function doc-string and several examples of using the funciton, contributed from the community

Clojure LSP describe-thing-here will return the doc-string and examples from clojuredocs.org (TODO: check Clojure LSP is using clojuredocs.org as a source of examples and if all editors support this (or if its just Emacs LSP UI)

Experiment in the REPL

calling the function in the REPL with various arguments, experiment by calling the function with different values

Evaluate the function call to a comment to keep a history of experiment results.

Read the source code of the function

For a deep understanding of a function, or to find further inspiration on how to write Clojure, take a look at the source code of a function.

Clojure LSP and Clojure aware editors allow navigation to the source code of any Clojure function on the Classpath.

clojuredocs.org also includes a link to the source code of the org.clojure/clojure project on GitHub

Clone the org.clojure/clojure project to search through the source code and run searches on the code to find use of a function.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Use the issue body as the article outline, covering function discovery, doc-strings, clojuredocs.org, REPL experimentation, and source navigation. First verify the TODO about whether Clojure LSP's describe-thing-here uses clojuredocs.org examples and which editors support it. Done means the article is published with accurate guidance and that uncertainty resolved.

Written by the indexing model from the issue text.

Assessment

Tech stack
clojure
Domain
documentation
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.