Open dlangBugzillaToGithub opened 10 years ago
Why is this an issue? all calls find which is non-nogc. Closing as invalid
Seems a legitimate enhancement request, and in line with the longer term goal of having Phobos be @nogc when possible. In this particular case, there doesn't appear to be any reason why the functionality implemented by std.algorithm.all cannot be @nogc. And, std.algorithm.find could be @nogc as well in this case.
Personally though, I would hesitate to write an enhancement request against each individual function in Phobos for every attribute, and instead have a larger placeholder ticket for larger blocks of Phobos, for example, a ticket for all of std.algorithm. The above is a policy question of course, but if done this way then this ticket could be closed as a duplicate of the larger ticket, rather than closing it as invalid.
As aside: std.algorithm.find is @nogc for certain argument types. Example:
@nogc @safe nothrow pure unittest
{
import std.algorithm : find;
import std.range : iota;
assert(find(iota(1,5), 3) == iota(3,5));
}
Valid enhancement request, so reopening. If closed, should have a justification indicating the mechanism expected to eventually achieve the enhancement, or an explanation of why it the request is invalid at the API level.
the problem here is auto-decoding and that it can throw an exception,
The following works as expected:
---
void main() @nogc {
import std.ascii: isDigit;
import std.algorithm: all;
import std.utf : byCodeUnit;
auto b = "12".byCodeUnit.all!isDigit;
}
---
It has long being proposed to disable auto-decoding by introducing an RCString. I'm not sure whether this should be kept open, because the issue is not on `all`'s side - all it does is calling `popFront` of string - which happens to be @nogc (due to throwing UTF Exceptions).
bearophile_hugs reported this on 2014-05-12T08:13:22Z
Transfered from https://issues.dlang.org/show_bug.cgi?id=12736
CC List
Description