You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found this interesting bug today as I was trying to move some of my code away from using macros. In the following, I'm using anonymous funcs, but I encountered the same bug in methods.
anon = () ->begin
tr =Trace()
tr() dofoo()
end
tr
end
This code works fine when you evaluate anon - it returns the Trace, which has been modified in the dynamo call, as expected. However, if I abstract out the call to foo:
anon = (call, args) ->begin
tr =Trace()
tr() docall(args...)
end
tr
end
the dynamo does not apply (i.e. the Trace is not mutated, as a side effect).
I found a related bug as well - here, foo is nullary function so you might expect this to work:
anon = call ->begin
tr =Trace()
tr() docall()
end
tr
end
but when I pass in foo as anon(foo), it throws:
LoadError: BoundsError: attempt to access 0-element Array{Any,1} at index [0]
This is obviously not what happens outside of the dynamo, i.e.:
anon2 = call ->begincall()
end
returns the result of calling foo.
Lastly, maybe I should show what the result of the dynamo is:
tr =Trace()
tr() dofoo()
endprintln(tr, [:val])
results in
|<> (:foo=>:bar) => (:q=>2) <>| val =1.0100076975990129||<> (:foo=>:bar) => (:q=>10) <>| val =-1.0067463813037731||<> (:foo=>:bar) => (:q=>9) <>| val =0.3533852496897451||<>:foo=>:y<>| val =-0.29516473908558977||<> (:foo=>:bar) => (:q=>3) <>| val =-0.3524573630007816...
when called outside of methods.
Edit: I'm guessing this is an @generated thing?
The text was updated successfully, but these errors were encountered:
femtomc
changed the title
Do dynamo broken for calls inside of methods
Do dynamo call broken for calls inside of methods
May 21, 2020
I found this interesting bug today as I was trying to move some of my code away from using macros. In the following, I'm using anonymous funcs, but I encountered the same bug in methods.
This code works fine when you evaluate
anon
- it returns theTrace
, which has been modified in the dynamo call, as expected. However, if I abstract out the call tofoo
:the dynamo does not apply (i.e. the
Trace
is not mutated, as a side effect).I found a related bug as well - here,
foo
is nullary function so you might expect this to work:but when I pass in
foo
asanon(foo)
, it throws:This is obviously not what happens outside of the dynamo, i.e.:
returns the result of calling
foo
.Lastly, maybe I should show what the result of the dynamo is:
results in
when called outside of methods.
Edit: I'm guessing this is an
@generated
thing?The text was updated successfully, but these errors were encountered: