std.dateparse reincarnation

Stewart Gordon smjg_1998 at yahoo.com
Thu Oct 27 17:56:40 PDT 2011


On 26/10/2011 02:44, Jonathan M Davis wrote:
<snip>
> I have not looked over them in detail, but from what I've seen, they're _very_
> similar - as in they took the C format specifiers and followed them in almost
> all (and maybe even all) cases but added a few of their own. But slight
> differences between them alone don't merit creating a whole new way of
> formatting dates and times.

It isn't a whole new way.  A number of date/time format string schemes that make use of 
repeated letters more or less as mine does have been created over time.  I guess because 
of the combination of natural look and feel, ease of implementation and ease of use.  And 
the L&F doesn't seem to me something that people will associate with one such scheme in 
particular, so there isn't much risk of confusion.

Moreover,
- If I'm not mistaken, usability is a design tenet of D.  It ought to just as well be 
taken into consideration in designing APIs.
- People who want strftime already have access to it.

Thinking about it now, I can see parallels with what you've been suggesting:

     C, C++, Java, etc. -> D
     printf -> writef, writefln

But given that strftime has evolved haphazardly, how do you plan to make meaningful 
improvements while keeping most of the specifiers the same?  By just picking a random 
as-yet-unused character whenever you want to add a new format specifier?

<snip>
> I have yet to look over your API in great detail,

Then don't criticise it for not having a certain feature when you haven't read far enough 
down to discover whether it has that feature.

> but from what I saw, it
> looked like _all_ alpha characters were considered flags, whereas strftime uses
> % to distinguish flags from other characters, just like printf and writeln do.
> I'll look over your API in more detail, but I would consider that a deal
> breaker if that's what it does.  There may very well be other things that
> you've done with it which are worth drawing from, but I fully intend to use
> flags like strftime does.

Is Phobos meant to be a community effort or a reflection of the preferences of one individual?

> Not doing so is unduly restrictive to what you can put in a format specifier.

To me it seems no more restrictive than D (even C) string syntax.  The need to save " for 
marking the end of the string doesn't place any restriction on what characters may be in 
the string.

And are you using "format specifier" to mean "flag" (what I've been using it to mean), 
"format string" or the format represented by it?

> It should be possible to put arbitrary strings in
> the format specifier just like you would with printf or writeln.

Which it is ... unless there's an obscure arbitrary string I've missed.

Stewart.


More information about the Digitalmars-d-announce mailing list