Comments (5)
Well, not in the specific example given.. but I can imagine a situation where it could arise:
(defn- frob-impl ;; maybe a protocol method which can't take 0 args
[{:keys [beep boop]}]
,,,)
(defn frob
"public API with extra convenience arity"
{:arglists (->> (:arglists (meta #'frob-impl))
(cons []))}
([] (frob default-opts))
([opts] (frob-impl opts)))
Of course it could be rewritten as (frob-impl default-opts)
, but figuring this out from the error stacktraces is not quite straightforward.
Either way if the syntax itself turns out to be officially unsupported or discouraged, it's probably not a good idea to build a feature around it? (I don't think it was definitively settled in the ask.clojure thread)
from clojure-lsp.
Note that function-a
as defined will fail to compile when its body contains a call to itself:
https://ask.clojure.org/index.php/13834/compiler-exception-dynamically-arglists-metadata-recursive
The interpretation given by @puredanger in the linked thread was that :arglists
in the attr-map should be restricted to literal quoted lists, so expressions to be evaluated like (:arglists (meta #'function-b))
should be at least discouraged (if not considered illegal).
from clojure-lsp.
To avoid this construction, one has to use alter-meta!
on the var after its creation, which I imagine is trickier to statically analyze:
(defn function-a [args]
(function-b args)
(alter-meta! #'function-a
assoc
:arglists (:arglists (meta #'function-b)))
;; or
(alter-meta! #'function-a
merge
(select-keys (meta #'function-b)
[:arglists :doc]))
from clojure-lsp.
It should also include :macro
meta for when you want to do this for a macro.
from clojure-lsp.
@yuhan0 I'm not sure if it matters here though, since you have one var copying another, it would never call itself no?
from clojure-lsp.
Related Issues (20)
- Allow disabling external keyword exclusions HOT 1
- Allow a null `rootUri` during initialization instead of crashing HOT 3
- Clojure LSP incorrectly marks `[\!\@]` as an error `<form> expected, got '\!\@'` HOT 2
- LSP Organize imports code action not working with a `#_` comment
- Add inline-function to commands HOT 3
- Publish checksums for nightly builds
- Add `deftest` to resolve-macro-as list HOT 2
- Internal Error -32603 when source files have non-ASCII characters in their path or name HOT 1
- Autocomplete missing vars HOT 1
- Autocomplete namespace aliases HOT 2
- Homebrew error: bad CPU type in executable HOT 3
- Copy memoized fn's doc when using `memoize` HOT 1
- Version `2024.08.05-18.16.00` (JVM) doesn't work out of the box without adding a fake `dev.weavejester/cljfmt` dependency
- Disabling the `:clojure-lsp/unused-public-var` linter also disables the `:clojure-lsp/different-aliases` linter
- Missing "unresolved symbol" if symbol ends in `*` and matches clojure.core symbol
- Create a separate option to exclude tests from the callers list when listing unused functions HOT 9
- CI action for nightly build should not pass if binaries cannot be built
- Exception thrown when clj-kondo diagnostic has severity `:ignore` HOT 4
- Add Basilisp support to clojure-lsp HOT 1
- Adding a linter for circular namespace dependencies HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from clojure-lsp.