Porting std.typecons
to Phobos 3
While JMD continues his work on Ranges V3 he mentioned that it would help him out if we could get started porting std.typecons
to Phobos 3. Therefore, I'd like to open this module up to the community to see what everyone thinks of the plan we've developed.
The first thing I'd like to consider is renaming to phobos.sys.types
. It is difficult to name std.typecons
because it is a grab-bag of type-related tools. We can continue with typecons
if desired, however, I would note that "cons" is not a standard abbreviation for "constructor", that'd be "ctor".
Second, JMD proposed that we re-organize this module into a package due to it's grab-bag nature. While I want to stress that we won't be doing this with every module Walter has asked that we evaluate modules for reasonable splits to make the files smaller and easier to read. Given the nature of std.typecons
we think that this module is an excellent candidate. My proposal is to break this module up by the categories in the document with the exception of Nullable
which will get it's own file module due to it's size.
Speaking of Nullable
, after a rather embarrassing situation with a Phobos 2 PR on Nullable
JMD and I agreed that it should be renamed as it does not actually behave like a nullable but instead behaves as an "Optional" type. We considered Optional
, Maybe
, and settled on Option
as that appears to the more popular naming choice in other languages and is almost as short as Maybe
. If you disagree I'd love to hear your case.
The last question is how we want to deal with existing bugs in V2 as we port the code to V3. My view is that it would be prudent to fix any bugs that have been opened as we go in both V2 and V3. Currently I've found a number of bugs against Nullable
and Tuple
, the two types I'd like to start with.
- First, some of these bugs are likely already fixed and just didn't get cleared by the bot for whatever reason, but I don't have the domain knowledge to know which, if any, already have been. If somebody could flag those I'll get them closed.
- Second, because some of these fixes will involve breaking changes, we need to decide which bugs we want to fix in both V2 and V3 and which we want to fix only in V3. If you could reply with "Both" or "V3" for fixes that'd be most helpful.
- Lastly, I found these via simple search through the bug list, if they don't apply, or if I am missing any, please let me know.
Nullable Bug List:
9637 - std.typecons.nullable and nullableRef functions (It looks to me like these exist, do the existing methods satisfy the issue?)
12323 - std.typecons.Nullable of a fixed-size array
13092 - std.algorithm.cartesianProduct of Nullable Tuple of strings array too
17615 - Deprecate using reference types for Nullable
21420 - Nullable.get default parameter is not lazy
22279 - alias this in Nullable(T, T nullValue) causes Error in writeln
24270 - Pointer to Nullable of recursive struct
24233 - T[].canFind(Nullable!T()) returns true when it used to return false
Tuple Bug List:
8494 - Return value for Tuple.opAssign
9593 - Optional type-free printing of a std.typecons.Tuple
12743 - tuple printing of alias names
13104 - std.typecons.tupleOp
15740 - Indexing a std.typecons.Tuple with names doesn't work in ctfe
15905 - Tuple Op Assignment Overload incorrect?
18426 - Conversion from Tuple with named fields to Tuple without named fields should work during compilation
20031 - Tuple.toString does not work with mutable toString
20228 - simple toString for Tuple!()s
20966 - std.typecons.Tuple cannot handle non-copyable types
21011 - Variant and tuples by index
21401 - Writelning a tuple ignores member's toString.
21429 - Cannot sort large tuple arrays at compile time
21888 - sorting medium sized tuples at compile time not possible
24138 - [REG 2.103] MemberFunctionsTuple does not see final functions
24285 - Cannot swap a std.typecons.Tuple (Open PR for this Issue)