On Tuesday, 23 June 2020 at 21:34:25 UTC, Paul Backus wrote:
If you're open to using Dub packages [...]
Because this is going to be used in almost every program I write,
I need to eliminate outside dependencies as an option.
Nonetheless, thanks for this suggestion.
[2]
https://pbackus.git
On Tuesday, 23 June 2020 at 16:14:20 UTC, Denis wrote:
by presenting an interface that only compiles when both cases
are covered, like fun().match((T t) => t, () => Error()).
A complete solution wrapped in a tidy package -- I like it.
Thanks for sharing.
If you're open to using Dub packages,
Perhaps this thread would have been better titled "Returning a
value and a status", and the question phrased as "What are your
preferred techniques?".
I'm planning to port some of my programs to D, so I'd like to
standardize on one or two techniques for handling this very
common situation, in
On Tuesday, 23 June 2020 at 04:01:45 UTC, Denis wrote:
(1) Assign an unused value for the flag (e.g. -1 when the
function returns an int), and return the combined value/flag.
This happens in some Phobos algorithms, and might be the most
common on this list.
(2) Return a tuple with the valu
Is there a preferred idiom in D for flagging special conditions
when returning from a function call? Here "special conditions"
refers to expected situations (e.g. reaching the end of
something, like EOF) rather than outright errors (so
exception-try-catch is inappropriate).
I've come across m