New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement meaningful fn metadata #129

Merged
merged 16 commits into from Apr 7, 2016

Conversation

Projects
None yet
1 participant
@arrdem
Collaborator

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 some commits Apr 5, 2016

Yak shave RT some
- Factor some initialization stuff more nicely
- Move doc/arglist initialization into core with others
Yak shave the compiler some
Normalize whitespace, remove commented code, this patch does it all
Add emitValue support for Namespaces
Previously, Namespaces as values would be emitted using read-eval. This
patch generates the obvious Namespace.findOrCreate code path instead.
Add ^:no-meta flag for fn*
This is an implementation detail which lets clients disable fancy
metadata on emitted fns. Needed for fixing lazy-seq serialization.
Suppress metadata on lazy-seq fns
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

This comment has been minimized.

Show comment
Hide comment
@arrdem

arrdem Apr 6, 2016

Collaborator

@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.

Collaborator

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 some commits Apr 7, 2016

Always implement IObj on Fns in the compiler
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

1 check passed

ci/circleci Your tests passed on CircleCI!
Details

@arrdem arrdem deleted the feature/fn-metadata branch Apr 7, 2016

@arrdem arrdem modified the milestone: 0.3.0 Apr 8, 2016

arrdem added a commit that referenced this pull request Apr 9, 2016

Merge tag 'v0.2.0' into develop
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 join this conversation on GitHub. Already have an account? Sign in to comment