<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, May 31, 2023 at 2:39 PM Attila Kelemen <<a href="mailto:attila.kelemen85@gmail.com">attila.kelemen85@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">The gain would be that I can use the upper bindings without worrying<br>
that there are new bindings. For my DI framework example, the problem<br>
is that a DI framework might want to bind a factory (maybe because it<br>
is a lazy singleton, or not a singleton at all), which is then queried<br>
ina nested scope. However, if we do not capture the current<br>
ScopedValue bindings at the time the DI framework captures its own<br>
factories, then the factories might behave differently depending on<br>
the context they were called for, and this would be unacceptable for a<br>
DI framework (you want very predictable behaviour for your factories).<br></blockquote><div><br></div><div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">With respect, I don't think you should approach the problem this way. If you have a DI framework which uses scoped values to determine what is bound, I think you'd be *much* better off binding a small number of contexts which are defined by the DI framework than you would be by binding everything that is available (which could be hundreds? thousands? ten thousands? of bound objects in real-world situations). You can very easily implement whatever functionality you want by wrapping the ScopedValue API without compromising the design principles of that API, rather than trying to make the ScopedValue API do something it is not intended for.</div></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">I for one do not *ever* want any external framework to be able to re-bind context objects that I define without going through APIs that I control, under any circumstances. Encapsulation is a feature not a bug.</div></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr">- DML • he/him<br></div></div></div>