(git HEAD) std.datetime spewing deprecation messages

Jonathan M Davis via Digitalmars-d digitalmars-d at puremagic.com
Thu Jun 5 17:34:23 PDT 2014


On Thu, 05 Jun 2014 23:54:49 +0200
Artur Skawina via Digitalmars-d <digitalmars-d at puremagic.com> wrote:

> I'm just saying that encouraging that kind of
> return-by-weakly-typed-pointers-with-string-selectors interfaces
> is /not/ a good idea; there are other, much better, options in D.

There's no weak typing here at all. The closest that there is to weak typing
is the fact that it will accept pointer to any integral type which risks
overflow if you select a type which is too small to hold the value. Everything
else about this is strongly typed. Accepting strings as template arguments is
something that core.time and std.datetime do in a number of places, and it has
proven to be extremely useful and flexible - and it really doesn't have
anything to do with types - be they weak or strong. It's used to indicate
which units a value is intended to represent. Those strings are the same
across core.time and std.datetime and template constraints do a wonderful job
of protecting against invalid string values. Remember that they're
_compile time_ values, not runtime, so any problems with them are caught when
you compile your code. It's not like any of this is being done dynamically.
It's taking advantage of D's wonderful metaprogramming capabilities.

And if you don't like the overload which accepts pointers, then just use the
overload that returns a struct (which then has member variables with the same
names as the strings, all of which are longs).

split as presented is incredibly straightforward and simple to use - and it's
quite type safe - whereas what you're suggesting is far more complicated and
to no real benefit as far as I can tell.

- Jonathan M Davis


More information about the Digitalmars-d mailing list