defcfn: set :arglists from the argtypes

Open Beginner friendly
#60 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
75/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active

Research direction

Start with the defcfn macro, comparing the plain form, which defines a var without :arglists, against the wrapper form, which already sets them from its fn tail. Derive :arglists from the argtypes in the plain form, following the issue's examples such as ([arg0]) and ([arg0 arg1 & args]), and let an :arglists key in the attribute map override it. Done when (:arglists (meta #'c-abs)) and (:arglists (meta #'c-open)) return the expected vectors and the existing tests still pass.

Written by the indexing model from the issue text.

Description

The plain form of defcfn defines a var without :arglists, so doc, eldoc and completion show no argument list:

(ffi/defcfn c-abs "abs" [:int] :int)
(:arglists (meta #'c-abs)) ;;=> nil

(ffi/defcfn c-open "open" [:string :int :&] :int)
(:arglists (meta #'c-open)) ;;=> nil

The wrapper form has them, from its fn tail.

defcfn could derive :arglists from the argtypes, for example ([arg0]) and ([arg0 arg1 & args]). An :arglists in the attribute map would take precedence.

Dominant language
Clojure
Stars
25
Forks
3
Avg merge
1m
Merged PRs (30d)
5

Getting set up

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.

More from babashka/ffi

All issues in babashka/ffi

Similar issues

More Clojure issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.