Make rt.util.utf publicly available

Jonathan M Davis newsgroup.d at
Mon Dec 3 17:02:30 UTC 2018

On Monday, December 3, 2018 3:40:03 AM MST Eduard Staniloiu via Digitalmars-
d wrote:
> Hello, everyone.
> I've been looking over Phobos' `std.utf` and druntime's
> `rt.util.utf` as there is some code duplication and I would like
> to start removing that.
> I want to be able to import some of the existing druntime
> functionality in Phobos, so we can remove the duplication: ex.
> isValidDchar, toUTF*, etc.
> I'm not able to do so, since, as far as I can tell, the `rt` is
> private: it's not part of the `druntime/import/` folder.
> Could you please tell me what's the reasoning behind this
> decision and what would be the course of action going forward?

At the moment, I can't remember the exact reasoning behind why the rt stuff
is separate, but if you want to consolidate its utf stuff so that Phobos can
import it, then just move it into core.internal.utf and have the rt stuff
import it.

That being said, this is not a simple case of druntime copying Phobos or
vice versa like it was with some traits. I don't know how close the
internals are in terms of the resultant logic when operating on arrays, but
std.utf's version of things is very much generic, operating on ranges, not
arrays specifically, and it uses some stuff from Phobos (especially in its
tests), making consolidating the code far less straightforward. So, while I
don't disagree that consolidating that code so that druntime and Phobos are
guaranteed to use the same logic for arrays is desirable, you're going to
need to be very careful about how you go about it if you want to make Phobos
depend on druntime in this case.

- Jonathan M Davis

More information about the Digitalmars-d mailing list