Skip to content
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

Update wrapper.jl - overload Base.merge for Wrapper type #47

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

uniment
Copy link

@uniment uniment commented Jan 9, 2024

Allows a Wrapper to be splatted, so that only a small handful of new functions need be defined, enabling patterns like this:

d, sw = simple_wrap()
function tickByTickAllLast(a, b, c, d, e, f, g, h) 
    #= =# 
end
w = Wrapper(; sw..., tickByTickAllLast) 
# `w` is exactly like `sw` but with a custom `tickByTickAllLast` callback

Allows a Wrapper to be splatted, so that only a small handful of new functions need be defined, enabling patterns like this:
```
d, sw = simple_wrap()
function tickByTickAllLast(a, b, c, d, e, f, g, h) 
    #= =# 
end
w = Wrapper(; sw..., tickByTickAllLast) 
# `w` is exactly like `sw` but with a custom `tickByTickAllLast` callback
```
@lbilli
Copy link
Owner

lbilli commented Jan 9, 2024

Thanks for the interest.
I'd like to point out that it's already possible to build or modify a Wrapper incrementally:

d, sw = simple_wrap()
function mycallback(a, b, c, d, e, f, g, h) 
    #= =# 
end

sw.tickByTickAllLast = mycallback

or, starting from scratch:

w = Jib.Wrapper()

w.tickPrice = function(a,b,c,d)
                #= =#
              end

@uniment
Copy link
Author

uniment commented Jan 10, 2024

Good point. This idea is rather more useful for constructing a type-stable NamedTuple wrapper instead:

d, sw = simple_wrap()
w = (; sw..., 
    updateMktDepth = function(args...) #= =# end,
    tickByTickAllLast = function(args...) #= =# end
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants