Skip to content
This repository was archived by the owner on Jul 12, 2023. It is now read-only.
This repository was archived by the owner on Jul 12, 2023. It is now read-only.

>defn does not support recursive functions #8

@julienfantin

Description

@julienfantin

👋 Using >defn on a recursive definition yields a Clojure compiler error.

(>defn walk
  [s u]
  (if-let [[_ v] (find s u)]
    (recur s v)
    u))
1. Caused by java.lang.UnsupportedOperationException
   Can only recur from tail position

The macro-expanded code looks a little something like this, which explains the above error:

(defn walk
  [s u]
  ... input checking ...
  (let [output (do ... body ...)]
    ... output checking ...
    output))

Would it be possible to rewrite the macro to make sure that the user's code remains in tail-position?
Perhaps by moving the output checking to a :post assertion?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions