How about this.. T maybe(T)(T * ptr, lazy T default) { if (ptr !is null) return *ptr; return default; } long p = maybe(get("A"), maybe(get("B"), maybe(get("C"), maybe(get("D"), maybe(get("E"), 0 )))));