Porting std.typecons to Phobos 3
Adam Wilson
flyboynw at gmail.com
Sat Nov 9 04:34:20 UTC 2024
## 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](https://issues.dlang.org/show_bug.cgi?id=9637) (It
looks to me like these exist, do the existing methods satisfy the
issue?)
[12323 - std.typecons.Nullable of a fixed-size
array](https://issues.dlang.org/show_bug.cgi?id=12323)
[13092 - std.algorithm.cartesianProduct of Nullable Tuple of
strings array too](https://issues.dlang.org/show_bug.cgi?id=13092)
[17615 - Deprecate using reference types for
Nullable](https://issues.dlang.org/show_bug.cgi?id=17615)
[21420 - Nullable.get default parameter is not
lazy](https://issues.dlang.org/show_bug.cgi?id=21420)
[22279 - alias this in Nullable(T, T nullValue) causes Error in
writeln](https://issues.dlang.org/show_bug.cgi?id=22279)
[24270 - Pointer to Nullable of recursive
struct](https://issues.dlang.org/show_bug.cgi?id=24270)
[24233 - T[].canFind(Nullable!T()) returns true when it used to
return false](https://issues.dlang.org/show_bug.cgi?id=24233)
### Tuple Bug List:
[8494 - Return value for
Tuple.opAssign](https://issues.dlang.org/show_bug.cgi?id=8494)
[9593 - Optional type-free printing of a
std.typecons.Tuple](https://issues.dlang.org/show_bug.cgi?id=9593)
[12743 - tuple printing of alias
names](https://issues.dlang.org/show_bug.cgi?id=12743)
[13104 -
std.typecons.tupleOp](https://issues.dlang.org/show_bug.cgi?id=13104)
[15740 - Indexing a std.typecons.Tuple with names doesn't work in
ctfe](https://issues.dlang.org/show_bug.cgi?id=15740)
[15905 - Tuple Op Assignment Overload
incorrect?](https://issues.dlang.org/show_bug.cgi?id=15905)
[18426 - Conversion from Tuple with named fields to Tuple without
named fields should work during
compilation](https://issues.dlang.org/show_bug.cgi?id=18426)
[20031 - Tuple.toString does not work with mutable
toString](https://issues.dlang.org/show_bug.cgi?id=20031)
[20228 - simple toString for
Tuple!()s](https://issues.dlang.org/show_bug.cgi?id=20228)
[20966 - std.typecons.Tuple cannot handle non-copyable
types](https://issues.dlang.org/show_bug.cgi?id=20966)
[21011 - Variant and tuples by
index](https://issues.dlang.org/show_bug.cgi?id=21011)
[21401 - Writelning a tuple ignores member's
toString.](https://issues.dlang.org/show_bug.cgi?id=21401)
[21429 - Cannot sort large tuple arrays at compile
time](https://issues.dlang.org/show_bug.cgi?id=21429)
[21888 - sorting medium sized tuples at compile time not
possible](https://issues.dlang.org/show_bug.cgi?id=21888)
[24138 - [REG 2.103] MemberFunctionsTuple does not see final
functions](https://issues.dlang.org/show_bug.cgi?id=24138)
[24285 - Cannot swap a
std.typecons.Tuple](https://issues.dlang.org/show_bug.cgi?id=24285) ([Open PR for this Issue](https://github.com/dlang/phobos/pull/8864))
More information about the Digitalmars-d
mailing list