Encapsulating trust

monarch_dodra via Digitalmars-d digitalmars-d at puremagic.com
Sun Aug 31 13:36:59 PDT 2014


On Sunday, 31 August 2014 at 13:47:42 UTC, Dmitry Olshansky wrote:
> What do you guys think?

I'd say add "trusted" to those function names:
"trustedCall"
"trustedAddrOf"

Because:
- "call" could mean a lot of things. It's not imidiatly obvious 
that it is meant for being trusted.
- "addrOf" is *also* used as an alternative for "&", especially 
in generic code, when you need the address of an attribute, as 
that attribute could actually be a property function. EG:
auto p = addrOf(r.front);
Nothing here implies trust.

Also, implementation wise, wouldn't it be possible to instead 
make `call` a template aliases itself away to `fun`, but with 
different attributes? The `auto fun(Args)(auto ref Args args)` 
tube approach has the disadvantages that it:
- prevents return by ref
- fails perfect forwarding of lvalues into rvalues.


More information about the Digitalmars-d mailing list