Bug 12656 – Some functions in std.ascii can be @nogc

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-04-26T17:10:00Z
Last change time
2014-05-06T08:05:20Z
Assigned to
nobody
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2014-04-26T17:10:34Z
void main() @nogc { import std.ascii: toLower, toUpper, isLower, isUpper; auto c1 = toUpper('a'); auto c2 = toLower('A'); auto b1 = isLower('a'); auto b2 = isUpper('A'); } DMD 2.066alpha gives: test.d(3,22): Error: @nogc function 'D main' cannot call non-@nogc function 'std.ascii.toUpper!char.toUpper' test.d(4,22): Error: @nogc function 'D main' cannot call non-@nogc function 'std.ascii.toLower!char.toLower' test.d(5,22): Error: @nogc function 'D main' cannot call non-@nogc function 'std.ascii.isLower' test.d(6,22): Error: @nogc function 'D main' cannot call non-@nogc function 'std.ascii.isUpper'
Comment #1 by dmitry.olsh — 2014-04-26T19:51:42Z
It's a simple enhancement. rejects-valid is for code that should work but doesn't due to _compiler_ bug. In this case you simply want some functions to have attribute they don't yet have. PRs are welcome.
Comment #2 by andrej.mitrovich — 2014-04-26T19:56:24Z
(In reply to Dmitry Olshansky from comment #1) > PRs are welcome. I wish we implemented @nogc semantics before marking everything as @nogc. Without proper semantic cecks now, what's going to happen is we're going to have a million errors *after* everything is marked as @nogc at the moment @nogc semantics are properly implemented. then it's going to be "good luck removing gc allocations now.". It's going to be too much work then. It's really a backwards development model. And it's being done on the master branch.
Comment #3 by bearophile_hugs — 2014-04-26T21:23:10Z
(In reply to Andrej Mitrovic from comment #2) > I wish we implemented @nogc semantics before marking everything as @nogc. > Without proper semantic cecks now, what's going to happen is we're going to > have a million errors *after* everything is marked as @nogc at the moment > @nogc semantics are properly implemented. I don't fully understand your points. Now @nogc semantics is already 80% implemented. What's missing is stuff like Issue 12642, that Walter so far has not commented on.
Comment #4 by andrej.mitrovich — 2014-04-26T21:28:25Z
(In reply to bearophile_hugs from comment #3) > (In reply to Andrej Mitrovic from comment #2) > > > I wish we implemented @nogc semantics before marking everything as @nogc. > > Without proper semantic cecks now, what's going to happen is we're going to > > have a million errors *after* everything is marked as @nogc at the moment > > @nogc semantics are properly implemented. > > I don't fully understand your points. Now @nogc semantics is already 80% > implemented. What's missing is stuff like Issue 12642, that Walter so far > has not commented on. Sorry, I was under the impression the semantics weren't in place. That's what I've read in the nogc pulls. Maybe things changed since then (a lot of changes go through every day). Disregard my rambling if I'm wrong.
Comment #5 by bearophile_hugs — 2014-05-06T08:05:20Z
(In reply to bearophile_hugs from comment #0) > void main() @nogc { > import std.ascii: toLower, toUpper, isLower, isUpper; > auto c1 = toUpper('a'); > auto c2 = toLower('A'); > auto b1 = isLower('a'); > auto b2 = isUpper('A'); > } Fixed: https://github.com/D-Programming-Language/phobos/commit/82377e5471411daf62acef480fccb5f487fec3ab