Jump to page: 1 2 3
Thread overview
Re: (git HEAD) std.datetime spewing deprecation messages
Jun 03, 2014
Jonathan M Davis
Jun 04, 2014
Sönke Ludwig
Jun 04, 2014
Nick Sabalausky
Jun 05, 2014
Jonathan M Davis
Jun 05, 2014
monarch_dodra
Jun 05, 2014
Brad Anderson
Jun 05, 2014
H. S. Teoh
Jun 05, 2014
Byron Heads
Jun 05, 2014
Artur Skawina
Jun 05, 2014
Artur Skawina
Jun 04, 2014
Kagamin
Jun 04, 2014
Meta
Jun 04, 2014
John Colvin
Jun 04, 2014
Meta
Jun 04, 2014
John Colvin
Jun 05, 2014
Chris Cain
Jun 03, 2014
Russel Winder
Jun 04, 2014
David Nadlinger
June 03, 2014
On Tue, 3 Jun 2014 07:21:12 -0700
"H. S. Teoh via Digitalmars-d" <digitalmars-d@puremagic.com> wrote:

> https://issues.dlang.org/show_bug.cgi?id=12846
>
> Since when is x.hours, x.minutes, etc., deprecated?

As of Sunday. The problem is that they seem to be very prone for misuse.
Not only do they not match what TickDuration uses those same names for (it
uses them for the equivelent of total!"hours"(), etc. rather than
get!"hours"(), etc.), which has come up a number of times before, but what
I've found at work (where we have a C++ port of Duration) is that pretty much
everyone keeps using get when they meant total, consistently causing subtle
bugs. So, I've come to the conclusion that the current design is just too
bug-prone, and by deprecating the individual getters and renaming get to
getOnly, I hope that that will seriously reduce the risk of misuse.

https://issues.dlang.org/show_bug.cgi?id=12837

>  Well, in any case, looks like std.datetime needs to be fixed.

I previously had those changes in a pull that was just merged, except that I removed them after Steven started complaining about

https://github.com/D-Programming-Language/druntime/pull/822

being merged (which is where the deprecations were introduced), on the theory that that would make reverting them harder. I have a new pull which fixes the two lines in std.datetime which were affected:

https://github.com/D-Programming-Language/phobos/pull/2228

- Jonathan M Davis
June 03, 2014
On Tue, 2014-06-03 at 10:00 -0700, Jonathan M Davis via Digitalmars-d wrote:
> On Tue, 3 Jun 2014 07:21:12 -0700
> "H. S. Teoh via Digitalmars-d" <digitalmars-d@puremagic.com> wrote:
> 
> > https://issues.dlang.org/show_bug.cgi?id=12846
> >
> > Since when is x.hours, x.minutes, etc., deprecated?
> 
> As of Sunday. The problem is that they seem to be very prone for misuse.

I think x.hours and x.minutes are fine per se. I would suggest deeper investigation of the perceived problems rather than just deprecate then remove.

> Not only do they not match what TickDuration uses those same names for (it uses them for the equivelent of total!"hours"(), etc. rather than get!"hours"(), etc.), which has come up a number of times before, but what I've found at work (where we have a C++ port of Duration) is that pretty much everyone keeps using get when they meant total, consistently causing subtle bugs. So, I've come to the conclusion that the current design is just too bug-prone, and by deprecating the individual getters and renaming get to getOnly, I hope that that will seriously reduce the risk of misuse.

This all sounds like implementation detail rather than API usage. I admit not having used this stuff in D, but the same basic system exists in Groovy and it works just fine.

[…]

-- 
Russel. ============================================================================= Dr Russel Winder      t: +44 20 7585 2200   voip: sip:russel.winder@ekiga.net 41 Buckmaster Road    m: +44 7770 465 077   xmpp: russel@winder.org.uk London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder

June 04, 2014
Just a minor note: What about just .only!"minutes", analogous .total!"minutes"? Removing both the .minutes shortcut and the short "get" method, pretty heavily increases verbosity, so shortening "getOnly" might be a good idea.
June 04, 2014
On Tuesday, 3 June 2014 at 17:35:42 UTC, Russel Winder via Digitalmars-d wrote:
> This all sounds like implementation detail rather than API usage.

How can an API problem be an implementation detail? I'm not quite getting your point here.

David
June 04, 2014
On 6/4/14, 9:12 AM, Sönke Ludwig wrote:
> Just a minor note: What about just .only!"minutes", analogous
> ..total!"minutes"?

Like -- Andrei

June 04, 2014
On Tuesday, 3 June 2014 at 17:01:15 UTC, Jonathan M Davis via Digitalmars-d wrote:
> As of Sunday. The problem is that they seem to be very prone for misuse.
> Not only do they not match what TickDuration uses those same names for (it
> uses them for the equivelent of total!"hours"(), etc. rather than
> get!"hours"(), etc.), which has come up a number of times before, but what
> I've found at work (where we have a C++ port of Duration) is that pretty much
> everyone keeps using get when they meant total, consistently causing subtle
> bugs. So, I've come to the conclusion that the current design is just too
> bug-prone, and by deprecating the individual getters and renaming get to
> getOnly, I hope that that will seriously reduce the risk of misuse.

Does one really needs only one component, but not the others? Maybe it should provide full computed broken form instead of separate components?

auto d=dur.breakUp;
d.hours; d.minutes; d.seconds;
June 04, 2014
On Wednesday, 4 June 2014 at 11:28:52 UTC, Kagamin wrote:
> Does one really needs only one component, but not the others? Maybe it should provide full computed broken form instead of separate components?
>
> auto d=dur.breakUp;
> d.hours; d.minutes; d.seconds;

In some glorious future where we can destructure tuples, you could do something like this:

(hours, minutes, seconds) = dur.parts;
June 04, 2014
On Wednesday, 4 June 2014 at 14:16:31 UTC, Meta wrote:
> On Wednesday, 4 June 2014 at 11:28:52 UTC, Kagamin wrote:
>> Does one really needs only one component, but not the others? Maybe it should provide full computed broken form instead of separate components?
>>
>> auto d=dur.breakUp;
>> d.hours; d.minutes; d.seconds;
>
> In some glorious future where we can destructure tuples, you could do something like this:
>
> (hours, minutes, seconds) = dur.parts;

Assuming hours, minutes and seconds are already declared, you can do this already

TypeTuple!(hours, minutes, seconds) = dur.parts;

A full working example of the syntax:


import std.typetuple;
import std.typecons;
import std.stdio;

void main()
{
	int a,b;
	TypeTuple!(a, b) = tuple(5, 8);
	assert(a == 5 && b == 8);
}
June 04, 2014
On Wednesday, 4 June 2014 at 15:51:58 UTC, John Colvin wrote:
> Assuming hours, minutes and seconds are already declared, you can do this already
>
> TypeTuple!(hours, minutes, seconds) = dur.parts;
>
> A full working example of the syntax:
>
>
> import std.typetuple;
> import std.typecons;
> import std.stdio;
>
> void main()
> {
> 	int a,b;
> 	TypeTuple!(a, b) = tuple(5, 8);
> 	assert(a == 5 && b == 8);
> }

*Assuming they're already declared* is the thing to note. There's little point in a tuple destructuring syntax if you have to declare the variables beforehand anyway.
June 04, 2014
On 6/4/2014 3:12 AM, Sönke Ludwig wrote:
> Just a minor note: What about just .only!"minutes", analogous
> .total!"minutes"? Removing both the .minutes shortcut and the short
> "get" method, pretty heavily increases verbosity, so shortening
> "getOnly" might be a good idea.

+1 for "only"
« First   ‹ Prev
1 2 3