Summary: writeln of empty Nullables too
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: rejects-valid
          Severity: enhancement
          Priority: P2
         Component: Phobos

--- Comment #0 from 2012-06-26 16:30:32 PDT ---
In D you can't print an empty Nullable:

import std.stdio: writeln;
import std.typecons: Nullable;
void main() {
    Nullable!int ni;

DMD 2.060alpha:

object.Exception@C:\dmd2\src\phobos\std\typecons.d(1218): Enforcement failed

But I'd like something similar to Haskell, where you are allowed to print an
empty Nullable (named Maybe):

GHCi, version 7.0.2: ...
Prelude> import Data.Maybe
Prelude Data.Maybe> Nothing :: Maybe Int

In D when the Nullable is empty I'd like writeln to print something like

As temporarily workaround I've added this method to Nullable, but it's not a
good general solution:

    string toString() const
        return this.isNull ? "EmptyNullable": text(get());

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to