Bug 12736 – @nogc std.algorithm.all

Status
REOPENED
Severity
enhancement
Priority
P4
Component
phobos
Product
D
Version
D2
Platform
x86
OS
All
Creation time
2014-05-12T08:13:22Z
Last change time
2024-12-01T16:21:08Z
Assigned to
No Owner
Creator
bearophile_hugs
See also
https://issues.dlang.org/show_bug.cgi?id=13458
Moved to GitHub: phobos#10053 →

Comments

Comment #0 by bearophile_hugs — 2014-05-12T08:13:22Z
void main() @nogc { import std.ascii: isDigit; import std.algorithm: all; auto b = "12".all!isDigit; } DMD 2.066alpha gives: temp.d(4,18): Error: @nogc function 'D main' cannot call non-@nogc function 'std.algorithm.all!(isDigit).all!string.all'
Comment #1 by razvan.nitu1305 — 2017-07-12T10:28:21Z
Why is this an issue? all calls find which is non-nogc. Closing as invalid
Comment #2 by jrdemail2000-dlang — 2017-07-12T17:39:07Z
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)); }
Comment #3 by jrdemail2000-dlang — 2017-07-13T14:19:28Z
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.
Comment #4 by greensunny12 — 2018-02-09T12:15:54Z
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).
Comment #5 by robert.schadek — 2024-12-01T16:21:08Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/phobos/issues/10053 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB