Hi Mr. @ISibboI
I poke around the threads and find related issue: #117, this is similar to what I am looking for, I will make a pull request if you aggree with my proposal.
We would like to expand the dot notation to attribute getter operator, object.field will be redirected to a user defined function dot(object, "field", ()), the user is responsbible for implementing it, now we are able to mimic object in a simple way.
Expected usage
eval_with_context_mut("
f = future("IC2312");
bid = f.bid * 1.001;
// call the method
f.buy(30.5, 100);
// return the prices
(bid, f.ask, f.mid, f.last)
",
&mut context);
User defined dot functions will handle this:
future("IC2312")
dot(f, "buy", (30.5, 100))
dot(f, "ask", ())
dot(f, "bid", ()), ...
Kindly review and discuss, thanks!
Hi Mr. @ISibboI
I poke around the threads and find related issue: #117, this is similar to what I am looking for, I will make a pull request if you aggree with my proposal.
We would like to expand the dot notation to
attribute getter operator,object.fieldwill be redirected to a user defined functiondot(object, "field", ()), the user is responsbible for implementing it, now we are able to mimic object in a simple way.Expected usage
User defined
dotfunctions will handle this:future("IC2312")dot(f, "buy", (30.5, 100))dot(f, "ask", ())dot(f, "bid", ()), ...Kindly review and discuss, thanks!