www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - chainable scopes

this is a library implementation based on the with expression[1] 
i posted a while ago and is kinda related to the ?. operator.

as we cant fully implement the above idea as a library i tried to 
what's possible which are basically chainable scopes[2].
implemented as 2 templates:

unchecked version: takes a Type and calls fun(type),
returns either type or return type of fun

auto call(alias fun, T)(T type)

checked version: takes a Type, does a check and if true, calls 
returns either type, return type of fun or ReturnType!(fun!T).init

auto checkCall(alias fun, T)(T type, T falseValue = T.init)

as im not an expert, are there any possible improvements?

(long post, only the top part is important the rest are just 
http://forum.dlang.org/thread/zgzgdknkeyahlbypixlu forum.dlang.org

[2] https://dpaste.dzfl.pl/5ecc288f572c
Jun 08 2016