<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Aug 18, 2016 at 8:56 PM, Alexandru Ermicioi via Digitalmars-d-announce <span dir="ltr"><<a href="mailto:digitalmars-d-announce@puremagic.com" target="_blank">digitalmars-d-announce@puremagic.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><span class="">On Tuesday, 16 August 2016 at 19:24:22 UTC, Rory McGuire wrote:<br>
</span><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><span class="">
On 16 Aug 2016 20:45, "Alexandru Ermicioi via Digitalmars-d-announce" < <a href="mailto:digitalmars-d-announce@puremagic.com" target="_blank">digitalmars-d-announce@puremag<wbr>ic.com</a>> wrote:<br>
</span><div><div class="h5"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
<br>
On Tuesday, 16 August 2016 at 14:25:10 UTC, Jacob Carlborg wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
<br>
On 2016-08-16 11:41, Alexandru Ermicioi wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
<a href="https://github.com/aermicioi/aedi" rel="noreferrer" target="_blank">https://github.com/aermicioi/a<wbr>edi</a><br>
</blockquote>
<br>
<br>
If you use:<br>
<br>
```d<br>
```<br>
<br>
For the code block you'll get syntax highlighting for D.<br>
</blockquote>
<br>
<br>
Thx, for info. Didn't know about such syntax. I'll update it with next<br>
</blockquote>
batch of modifications.<br>
<br></div></div><span class="">
Can this be used to do function<br>
currying? <a href="http://stackoverflow.com/questions/36314/what-is-currying" rel="noreferrer" target="_blank">http://stackoverflow.com/quest<wbr>ions/36314/what-is-currying</a><br>
<br>
Seems like an interesting feature. I imagine it would use templates or a wrapper struct instead of wrapped functions though.<br>
</span></blockquote>
<br>
Thank you, for sharing with an idea :)<br>
<br>
I'm not sure if I understand your proposition correctly.<br>
<br>
I assume that you meant the call of register function on container to register an object in it. If so, by applying currying, we would get something like:<br>
<br>
container.register!Type()("con<wbr>structor")("setter", "setterArg"); // And so on.<br>
<br>
It's an interesting idea, but I'm not sure if it will allow an easy customization of register api :(.<br>
<br>
Could you please explain it in more detail?<br>
</blockquote></div><br></div><div class="gmail_extra">No probs, example:</div><div class="gmail_extra">/////</div><div class="gmail_extra">module m1;</div><div class="gmail_extra">/// this module contains standard functions / classes etc...</div><div class="gmail_extra">auto func1(Type1 v1, Type2 v2, Type3 v3) {</div><div class="gmail_extra"> // do awesome stuff with all three instances</div><div class="gmail_extra">}</div><div class="gmail_extra"><br></div><div class="gmail_extra">class A {</div><div class="gmail_extra"> Type4 v4;</div><div class="gmail_extra"> Type5 v5;</div><div class="gmail_extra"> this(Type4 v4, Type5 v5) {</div><div class="gmail_extra"> this.v4 =v4; this.v5=v5;</div><div class="gmail_extra"> }<br> void changeMode(Type2 v2) {<br> v4.asdf(v2);<br> }<br> void opApply(...) {</div><div class="gmail_extra"> /// do normal stuff with all these manually passed in instances</div><div class="gmail_extra"> }</div><div class="gmail_extra">}</div><div class="gmail_extra"><br></div><div class="gmail_extra">module auto_deps_m1;</div><div class="gmail_extra">/// this module has the curryied versions of the original functions and classes from m1;</div><div class="gmail_extra">/// What I think would be cool, and I thinks its possible, would be to automatically inject default instance parameters into classes (the Object), and functions.</div><div class="gmail_extra">/// so func1 could for example be exposed in this module as:</div><div class="gmail_extra">auto func1(Type2 v2) {</div><div class="gmail_extra"> /// yeah, don't worry about passing the other stuff in, it was all setup during dependency registration</div><div class="gmail_extra">}</div><div class="gmail_extra"><br></div><div class="gmail_extra">class A {</div><div class="gmail_extra"> Type4 v4; /// inject this<br> Type5 v5;<br> this(Type5 v5) {</div><div class="gmail_extra"> this.v5 = v5; // we never registered a Type5 during dependency registration</div><div class="gmail_extra"> this.v4.changeMode(registered_v2); /// this got moved here due to compile time dependency registration </div><div class="gmail_extra"> }<br> void opApply(...) {<br> // do stuff, and all we had to supply in other modules that depend on this one is the instance for v5</div><div class="gmail_extra"> }</div><div class="gmail_extra">}</div><div class="gmail_extra"><br></div><div class="gmail_extra">//////</div><div class="gmail_extra"><br></div><div class="gmail_extra"><br></div><div class="gmail_extra">The function example is what I was thinking initially, but I don't see why it couldn't be done with structs and classes as well.</div><div class="gmail_extra"><br></div><div class="gmail_extra">I guess in m2 the code the programmer writes would be similar to:</div><div class="gmail_extra">mixin(registrationService.ct_register!(func1));</div><div class="gmail_extra"><br></div><div class="gmail_extra">etc..</div><div class="gmail_extra"><br></div><div class="gmail_extra">If its not possible right now I'd imagine its fairly close to possible.</div><div class="gmail_extra"><br></div><div class="gmail_extra"><br></div><div class="gmail_extra">disclaimer: I'm not very familiar with dependency injection in anything but Javascript with AngularJS.</div><div class="gmail_extra"><br></div></div>