[challenge] Bounded types

Yao G. yao.gomez at spam.gmail.com
Tue Oct 12 12:52:58 PDT 2010


On Mon, 11 Oct 2010 20:37:25 -0500, Philippe Sigaud  
<philippe.sigaud at gmail.com> wrote:

>>> http://bitbucket.org/gomez/yao-library/src/tip/src/yao/datetime/core.d#cl-551
>
> Wow, I never put pure nothrow around my constructors. Maybe I should.

Yes. I'm trying to make an habit of that. But sometimes is a pain in the  
rear end because a great deal
of Phobos code is neither pure or @safe (or nothrow).

> The wrapping behaviour is interesting. All this could be ported into a
> policy. It's a bit like clipping a texture, what kind of possibility
> do we have?

Yes. In the code is used mostly to convert from hours to days, in a  
DateTime struct. The time must be normalized
to less than 24 hours (the time part of the day) and all the extra time is  
converted to days in chunks of 24 hours.
The IntWrapper struct helps a lot with this:

http://bitbucket.org/gomez/yao-library/src/tip/src/yao/datetime/time.d#cl-1504

> [snip]
>
> I'm also interested by your IntAdapter (aka int + infinity), I did
> something similar once, to allow for slicing on infinite ranges.

That struct adds pseudo +/- infinite and NAN support to some of the Date  
and Time types. That way you can have +infinite dates,
which can be used to indicate that, for example, an event is cancelled  
"until further notice" or something will be finished
"when it's done", etc.

-- 
Yao G.


More information about the Digitalmars-d mailing list