-
Notifications
You must be signed in to change notification settings - Fork 2
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
Replace gen with fn, gen.{trace,splice} => gen.dynamic.{trace!,splice!} #41
Conversation
Codecov Report
@@ Coverage Diff @@
## main #41 +/- ##
==========================================
- Coverage 66.36% 66.30% -0.06%
==========================================
Files 16 16
Lines 666 653 -13
Branches 22 16 -6
==========================================
- Hits 442 433 -9
- Misses 202 204 +2
+ Partials 22 16 -6
|
src/gen/dynamic.cljc
Outdated
`(binding [dynamic.trace/*trace* dynamic.trace/no-op] | ||
~@body)) | ||
|
||
(defmacro gen |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(this is just an alias now)
src/gen/dynamic.cljc
Outdated
|
||
(defrecord DynamicDSLFunction [clojure-fn] | ||
(defmacro trace! [addr [f & xs]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you really want to go all functions (which I DO!) then we'd change this to a function and change the calls to
(trace! gf x1 x2 ...)
and don't try to make it look like a function call. Then trace!
is conceptually like apply
.
0d3bc33
to
cc5017c
Compare
(untraced | ||
(apply clojure-fn x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15 x16 x17 x18 x19 x20 xs))) | ||
(applyTo [_ xlist] | ||
(untraced (.applyTo ^clojure.lang.IFn clojure-fn xlist)))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this untraced
wrapper was missing on main
for clj
and cljs
.
|
||
(defn trace-form? | ||
"Returns true if `form` is a trace form." | ||
[form] | ||
(and (seq? form) | ||
(= `gen/trace (first form)))) | ||
(#{'trace! 'dynamic/trace! 'gen.dynamic/trace!} (first form)))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a hack for now, but I want to get things working in SCI before we take on a cleaner solution.
(or (symbol? gfn) | ||
(and (seq gfn) | ||
(= `gen (first gfn))))))))) | ||
(#{'splice! 'dynamic/splice! 'gen.dynamic/splice!} (first form)))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here.
cc5017c
to
adfeeed
Compare
b4c6186
to
58e8b3a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestions:
- Add a comment above the hack linking it to the issue you made.
- Extract out the code that changes
(trace! …)
such that the call isn't wrapped.- Have McCoy or someone from the Gen team review that.
- Change the commit scope from
feat
torefactor!
if, as it seems, this isn't actually introducing new functionality.
58e8b3a
to
db72f04
Compare
This PR:
gen.{trace,splice}
togen.dynamic.{trace!, splice!}
to prevent clashes between these functions and thegen.trace
namespacegen.dynamic.trace/without-tracing
becomesgen.dynamic/untraced
trace
to(trace! <addr> <gf> & <args>)
, simplifying the macro implementation and bringing it more inline with GenJAX and Gen.jl (similar change tosplice
)trace!
andsplice!
called outside of agen
macro will now error.untraced
call around the biggest arity ofinvoke
forDynamicDSLFunction
There is a lurking bug that this PR exposed.
trace!
andsplice!
will currently only work if called astrace!
,dynamic/trace!
orgen.dynamic/trace!
. If you bind the symbol some other way, liked/trace!
, tracing will error.We can fix this with some clever macro work for the cljs and SCI environments, but I want to hold off in this PR.