Thread overview | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
June 11, 2014 Cannot understand deprecation message recently added to Phobos | ||||
---|---|---|---|---|
| ||||
Can somebody explain the meaning of split in the error message Deprecation: function core.time.Duration.weeks is deprecated - Please use split instead. weeks was too frequently confused for total!"weeks". given by function shortDurationString() at https://github.com/nordlow/justd/blob/master/pprint.d |
June 11, 2014 Re: Cannot understand deprecation message recently added to Phobos | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nordlöw | On Wednesday, 11 June 2014 at 20:59:25 UTC, Nordlöw wrote: > Can somebody explain the meaning of split in the error message > > Deprecation: function core.time.Duration.weeks is deprecated - Please use split instead. weeks was too frequently confused for total!"weeks". > > given by function > > shortDurationString() > > at > > https://github.com/nordlow/justd/blob/master/pprint.d https://github.com/D-Programming-Language/druntime/pull/825 |
June 11, 2014 Re: Cannot understand deprecation message recently added to Phobos | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nordlöw | On Wed, 11 Jun 2014 16:59:24 -0400, Nordlöw <per.nordlow@gmail.com> wrote:
> Can somebody explain the meaning of split in the error message
>
> Deprecation: function core.time.Duration.weeks is deprecated - Please use split instead. weeks was too frequently confused for total!"weeks".
>
> given by function
>
> shortDurationString()
>
> at
>
> https://github.com/nordlow/justd/blob/master/pprint.d
Actually, that may not be a valid deprecation message.
All the other unit functions do not get the total number of units, but there are not larger units supported by Duration. In fact, dur.weeks was the equivalent of dur.total!"weeks".
You can safely change your code to use total!"weeks" instead.
Jonathan, can we update this deprecation message?
The function is going away because of the confusion with smaller units. For example, dur.seconds could be confused as "the number of seconds in this duration", but it's really "the number of seconds that do not make up a whole minute in this duration". Basically, it's the mod remainder for the seconds.
-Steve
|
June 11, 2014 Re: Cannot understand deprecation message recently added to Phobos | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kapps | On Wednesday, 11 June 2014 at 21:06:42 UTC, Kapps wrote:
> On Wednesday, 11 June 2014 at 20:59:25 UTC, Nordlöw wrote:
>> Can somebody explain the meaning of split in the error message
>>
>> Deprecation: function core.time.Duration.weeks is deprecated - Please use split instead. weeks was too frequently confused for total!"weeks".
>>
>> given by function
>>
>> shortDurationString()
>>
>> at
>>
>> https://github.com/nordlow/justd/blob/master/pprint.d
>
> https://github.com/D-Programming-Language/druntime/pull/825
Ok, I replaced
immutable weeks = dur.weeks();
with
immutable weeks = dur.split!"weeks";
but my code using it
if (weeks)
{
if (weeks < 52)
fails as
pprint.d(39,9): Error: expression weeks of type immutable(SplitUnits) does not have a boolean value
pprint.d(41,13): Error: incompatible types for ((weeks) < (52)): 'immutable(SplitUnits)' and 'int'
Sorry but I don't understand what to do with the struct SplitUnits.
|
June 11, 2014 Re: Cannot understand deprecation message recently added to Phobos | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | > You can safely change your code to use total!"weeks" instead.
Ok.
Thx
|
June 11, 2014 Re: Cannot understand deprecation message recently added to Phobos | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kapps | > https://github.com/D-Programming-Language/druntime/pull/825 I updated https://github.com/nordlow/justd/blob/master/pprint.d with two versions of shortDurationString(). DMD picks the right one using static if (__VERSION__ >= 2066L) // new else // old I hope I it right this time. |
June 12, 2014 Re: Cannot understand deprecation message recently added to Phobos | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kapps | On Wed, 11 Jun 2014 17:06:41 -0400, Kapps <opantm2+spam@gmail.com> wrote: > On Wednesday, 11 June 2014 at 20:59:25 UTC, Nordlöw wrote: >> Can somebody explain the meaning of split in the error message >> >> Deprecation: function core.time.Duration.weeks is deprecated - Please use split instead. weeks was too frequently confused for total!"weeks". >> >> given by function >> >> shortDurationString() >> >> at >> >> https://github.com/nordlow/justd/blob/master/pprint.d > > https://github.com/D-Programming-Language/druntime/pull/825 Now fixed, is the message clearer for you? https://github.com/D-Programming-Language/druntime/pull/837 -Steve |
Copyright © 1999-2021 by the D Language Foundation