Skip to content

Minimize the cost of s/fn-schema support for s/letfn  #431

Open

Description

@frenchy64

#430 revealed a faster way to support s/fn-schema via metadata. We should look into the performance improvements of using the same strategy for s/letfn and then perhaps deprecate schematize-fn.

Idea:

(s/letfn [(f [a ...])]
  ...)
=>
(letfn [(f [a ...])]
  (let [f ^{:schema ...} (fn [a ..] (f a ...)))]
    ...))

Activity

  1. frenchy64 commented on Nov 6, 2021

    @frenchy64
    ContributorAuthor

    Another idea, but unfortunately it doesn't work:

    user=> (letfn* [f ^:a (fn f [])] (meta f))
    CompilerException java.lang.ClassCastException: class clojure.lang.Compiler$MetaExpr cannot be cast to class clojure.lang.Compiler$ObjExpr (clojure.lang.Compiler$MetaExpr and clojure.lang.Compiler$ObjExpr are in unnamed module of loader 'app'), compiling:(/private/var/folders/s5/309818k92r92zn9c_nzvmnzc0000gn/T/form-init5989770558247704827.clj:1:1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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