chainable scopes
ArturG via Digitalmars-d
digitalmars-d at puremagic.com
Wed Jun 8 14:08:28 PDT 2016
this is a library implementation based on the with expression[1]
idea
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
do
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
fun(type),
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
examples)
[1]
http://forum.dlang.org/thread/zgzgdknkeyahlbypixlu@forum.dlang.org
[2] https://dpaste.dzfl.pl/5ecc288f572c
More information about the Digitalmars-d
mailing list