try/catch idiom in std.datetime
Jonathan M Davis
jmdavisProg at gmx.com
Thu Nov 21 08:35:14 PST 2013
On Thursday, November 21, 2013 16:38:48 Jesse Phillips wrote:
> On Thursday, 21 November 2013 at 07:44:44 UTC, Jonathan M Davis
>
> wrote:
> > As I understand it, when Walter is talking about a validator
> > function, _all_
> > it does is validate the input. It doesn't operate on the data
> > beyond doing validation
>
> I doubt Walter first checks that a file is a valid D program
> before tokenizing. More importantly he probably would not go for
> such a change.
Of course not, which makes his argument all the odder. Maybe he misunderstood
what fromISOExtString does when responding to my argument that it made no
sense to use a separate validator function for it.
> The thing is, ISO String isn't a date, we first need to create a
> date and in doing so we validate it is valid and never have to
> check again.
Agreed. But Walter is specifically arguing for doing validation in separate
functions from those that do the work, which would mean having something like
isValidateISOExtString which could be called fromISOExtString and then
requiring that the string passed to fromISOExtString be valid or you get
undefined behavior (in release at least, where there would be no assertions) as
opposed to doing the checking in fromISOExtString. It's not necessarily a bad
idea in the general case, but in this particular case, it makes no sense IMHO.
However, when I argued that, for some reason Walter seemed to think that it
was a perfect example of a case where there should be a separate validator
function. So, maybe there's a miscommunicaton with regards to what
fromISOExtString does.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list