Em qui., 13 de mai. de 2021 às 13:36, Alan Snyder <javali...@cbfiddle.com>
escreveu:


> >> Is this a common practice? Doesn’t it point to a deficiency in the
> library API?
> >
> > Not necessarily. For example, say you want to give access to a particular
> > resource (a log stream, say) to trusted callees. Nobody AFAIK passes a
> log
> > stream as an explicit argument through business logic because that's just
> > too much clutter.
> >
>
> That sounds interesting, but I’m not following how scope locals would be
> used to solve this problem.
>

It appears to me that, in this context, scoped locals is inserting itself
inside a hierarchy of "overrides".
We already have mechanisms which provide "context" capable of carrying
"overrides", such as process environment variables and JVM system
properties.
Those are too global for certain uses such as "overriding" a single method
call.
So, in a great hierarchy of "overrides", we would have, from the largest to
the smallest: process environment variables > JVM system properties > *scoped
locals* > method call parameters.
Things like these are recurrent in the design of "I/O cancelability", where
people are always discovering the need for things like "timeout scopes".
It could be argued that "cancelable" APIs must have some "cancellation
token " parameter.
But there are cases where some domain interface, which was never designed
with this in mind, must be implemented over network protocols.
This is the case when you must implement a KeyStore or a Cipher with
remotely managed private keys.
Since you cannot alter KeyStore to pass a "cancellation token" to single
methods, you must insert the token as a sort of "override" thing in some
parallel storage.

-- 
Pedro Lamarão
https://www.prodist.com.br
Securing Critical Systems
Tel: +55 11 4380-6585

Antes de imprimir esta mensagem e seus anexos, certifique-se que seja
realmente necessário.
Proteger o meio ambiente é nosso dever.
Before printing this e-mail or attachments, be sure it is necessary.
It is in our hands to protect the environment.

Reply via email to