Skip to content
This repository has been archived by the owner on Jan 28, 2019. It is now read-only.

Implement meaningful fn metadata #129

Merged
merged 16 commits into from
Apr 7, 2016
Merged

Implement meaningful fn metadata #129

merged 16 commits into from
Apr 7, 2016

Conversation

arrdem
Copy link
Collaborator

@arrdem arrdem commented Apr 6, 2016

This changeset tweaks the compiler to emit introspectable Var use set and arity information on Fns.

At present, a Fn can have the following metadata:

  • :uses, the set of Vars directly used by this Fn

Other metadata may be added in the future given more consideration.

2016-04-06-170102_952x702_scrot

Fixes #127

Thanks to @mikera for some prior art on this matter, and RFC on this implementation.

arrdem added 12 commits April 6, 2016 16:29
- Factor some initialization stuff more nicely
- Move doc/arglist initialization into core with others
Normalize whitespace, remove commented code, this patch does it all
Previously, Namespaces as values would be emitted using read-eval. This
patch generates the obvious Namespace.findOrCreate code path instead.
This is an implementation detail which lets clients disable fancy
metadata on emitted fns. Needed for fixing lazy-seq serialization.
Vars don't serialize and it makes no sense to serialize them, so since
lazy-seq fns are closed over and can't really be captured as values and
introspected just suppress metadata emission on them.
@arrdem arrdem force-pushed the feature/fn-metadata branch from 8351243 to b5fbda7 Compare April 6, 2016 21:30
@arrdem arrdem force-pushed the feature/fn-metadata branch from b5fbda7 to cec8af9 Compare April 6, 2016 22:05
@arrdem
Copy link
Collaborator Author

arrdem commented Apr 6, 2016

@Bronsa points out that, as presently implemented, calling withMeta on AFn will return a new anonymous AFn which masks all methods and uses applyTo for everything. This means that putting metadata on the Fn itself is a pretty crappy idea until fn* emission can be fixed to implement withMeta itself.

This is doable, in fact it should be a pretty simple copy/paste job from the implementation of reify* which must implement IObj in the code generator. However I'm seeing weird shit and think I may have broken AOT somehow so I'm gonna circle back to this another day.

arrdem added 2 commits April 7, 2016 13:54
Does away with the old `AFunction.withMeta()` implementation which
operates by adding a wrapper Fn object which calls applyTo on the
wrapped Fn, and instead uses the existing compiler code path for
emitting appropriate `Fn.meta()` and `Fn.withMeta()` implementations.
@arrdem arrdem merged commit 6482472 into develop Apr 7, 2016
@arrdem arrdem deleted the feature/fn-metadata branch April 7, 2016 19:34
@arrdem arrdem modified the milestone: 0.3.0 Apr 8, 2016
arrdem added a commit that referenced this pull request Apr 9, 2016
Vist 0.2.0 upon the world

This release focuses on fleshing Jaunt out as a separate platform atop
Clojure, adding support for the `.jnt` file extension and the `:jnt`
reader conditional directive. Other changes include the deprecation and
automatic refactoring hinting of `use` and `refer`, the addition of
`^:uses` metadata fo `AFn` instances in support of future static
analysis work and migration to JDK8 for the entire project although few
JDK8 features are used at this time.

- [#131](#131) Add support for `.jnt` files (@arrdem).
  - `load-file` now chooses the first file of `.class`, `.jnt`, `.clj`, `.cljc`.
- [#129](#129) Emit `^:uses` metadata on `Fn` instances (@arrdem).
- [#126](#126) Add reader support for `Infinity`, `NaN` (@arrdem).
- [#123](#123) Add support for `:jnt` in reader conditionals (@arrdem).
  - Update to Java 1.8
  - Implement `java.lang.Iterable` over `clojure.lang.Seqable` using a Java 8 interface default method
  - Add `clojure.lang.RT.union(set, seq):set`
- [#122](#122) Catch and print exceptions encountered loading `user.clj` (@arrdem).
- [#116](#116) Deprecate `clojure.core/refer` (@arrdem).
  - Deprecate `clojure.core/refer`
  - Refactor `clojure.core/refer` to emit a warning describing how to rewrite refer into require.
- [#117](#117) Fix typo in arglists (@arrdem).
- [#112](#112) Self-refactoring use (@arrdem).
  - Add `clojure.core/sift`.
  - Refactor `clojure.core/use` to emit a warning describing how to rewrite use into require/refer.
  - Refactor out uses of `use`.
- [#111](#111) Add a warning when expanding deprecated macros (@arrdem).
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant