[phobos] Split std.datetime in two?

Lars Tandle Kyllingstad lars at kyllingen.net
Thu Feb 10 01:49:24 PST 2011


On Wed, 2011-02-09 at 21:54 -0800, Jonathan M Davis wrote:
> Okay. On the whole, I'm fine with std.datetime being one, large module. It works 
> fine from a maintenance standpoint, and while some people have complained about 
> the large number of unit tests getting in the way of finding stuff in the file, I 
> find that having the unit tests right next to the functions like that to really 
> help with maintenance.
> 
> I do have one concern however. As there's a fair bit of functionality in there, 
> there's a lot of documentation, and I'm afraid that the documentation may be a 
> bit overwhelming to someone trying to figure out how to use std.datetime. On the 
> whole, everything in there is quite easy to use, but there's a lot of it.
> 
> So, what I'm wondering is if it would be worthwhile to split out the interval 
> and range stuff into a separate module. That wouldn't hugely reduce the size of 
> the module, but it _would_ make the documentation more manageable. It also has 
> the nice side effect that the three main date/time concepts would then be in 
> three separate modules. The duration types were already split into core.time, 
> because Sean needed a duration type for some stuff in druntime. The time points 
> would stay in std.datetime. And the time intervals would then be in 
> std.timeinterval (or whatever we wanted to call it). The documentation would 
> therefore be more easily digestible. Also, if and when I get around to coming up 
> with more date/time functionality, the main area that I'd likely be putting it 
> would be in the intervals and ranges (in particular, at some point, I'd like to 
> create functionality to handle date recurrence patterns), so the bulk of the new 
> stuff would end up in the smaller of the two time-related modules in Phobos, 
> thereby evening out their size a bit.
> 
> Again, I don't really have a problem with std.datetime being as big as it is 
> (though some people do), but I _am_ concerned that the documentation is going to 
> be a bit hard to digest for newcomers. It's not complicated, but there's a lot 
> of it. So, I'm thinking that there would be some value in create 
> std.timeinterval for the date/time interval and range functionality, thereby 
> reducing the size of std.datetime and making it easier for newcomers to digest. 
> It will also make it easier to find the interval and range-related functionality 
> if that's what you're looking for.
> 
> So, what are everyone else's thoughts on this? Andrei and Walter favored 
> std.datetime being one giant module, and I don't exactly disagree, but I do 
> think that splitting _some_ of its functionality out would make it more 
> digestible, and I know that there are at least a few folks who think that 
> std.datetime is just plain too large.

I don't think std.datetime should be split.  Keeping it in one file is
consistent with the way the other Phobos modules are organised.  Rather,
the Phobos documentation as a whole (and possibly DDOC itself) should be
improved.

If it were to be split, I think it would be better to split it into
std.calendar (Date, TimeOfDay, DateTime), and std.time (SysTime,
StopWatch).

Note that I'm not saying I think Phobos' flat module hierarchy is the
best one.  On the contrary, now that the library is getting so big, it
would probably be better to have it one level deeper
(std.algorithm.search, std.algorithm.sort, std.time.calendar,
std.time.systime, etc.), but I guess it's too late for that.

-Lars



More information about the phobos mailing list