Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

on gems/functional-programming use of deprecated resources - replacement proposal #255

Closed
astoliar opened this issue Apr 1, 2018 · 2 comments

Comments

@astoliar
Copy link
Contributor

astoliar commented Apr 1, 2018

The example at https://tour.dlang.org/tour/en/gems/functional-programming use a deprecated resources.
If you run it, you will get:
onlineapp.d(38): Deprecation: function onlineapp.main.benchmark!(test).benchmark is deprecated - Use std.datetime.stopwatch.benchmark.

It is not at issue at the moment, std.datetime.benchmark will be removed from the docs in October and from Phobos one year later. TickDuration seems to follow the same plan.

Anyway, a way to rewrite it to avoid those resources is to replace:

import std.datetime : benchmark, to;
by
import std.datetime.stopwatch : benchmark;

and
foreach (i; 0 .. 10) benchmark!test(1)[0] .to!("msecs", double) .reverseArgs!writefln (" took: %.2f miliseconds");
by
foreach (_; 0 .. 10) ( benchmark!test(1)[0] .total!"usecs"/1000.0 ) .reverseArgs!writefln (" took: %.2f miliseconds" );

There are several ways to replace it. The proposal is one that tries to change as little as possible.
Note: the change from 'i' to '_' is of course not necessary (but 'i' is not necessary either).

Do you think the replacement is convenient? If so, do you mind if I send a PR with this one?

@wilzbach
Copy link
Member

wilzbach commented Apr 1, 2018

If so, do you mind if I send a PR with this one?

No at all.
Please, there's no need to ask before sending a PR (especially if explaining the change takes longer than sending it). Simply do ;-)
Thanks!

@wilzbach
Copy link
Member

wilzbach commented Apr 2, 2018

Fixed by #257. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants