Bug 8920 – iota should work with all integral types
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-10-31T04:00:00Z
Last change time
2013-02-03T16:35:16Z
Keywords
pull
Assigned to
andrej.mitrovich
Creator
bearophile_hugs
Comments
Comment #0 by bearophile_hugs — 2012-10-31T04:00:50Z
import std.range: iota;
void main() {
foreach (i; iota(cast(byte)0, cast(byte)10)) {}
foreach (i; iota(cast(ubyte)0, cast(ubyte)10)) {}
foreach (i; iota(cast(short)0, cast(short)10)) {}
foreach (i; iota(cast(ushort)0, cast(ushort)10)) {}
foreach (i; iota('a', 'f')) {}
}
DMD 2.061alpha shows some iota() problems with arguments of other types:
...\dmd2\src\phobos\std\range.d(4834): Error: cannot implicitly convert expression (cast(int)this.pastLast - 1) of type int to inout(byte)
test.d(3): Error: template instance std.range.iota!(byte,byte) error instantiating
...\dmd2\src\phobos\std\range.d(4834): Error: cannot implicitly convert expression (cast(int)this.pastLast - 1) of type int to inout(ubyte)
test.d(4): Error: template instance std.range.iota!(ubyte,ubyte) error instantiating
...\dmd2\src\phobos\std\range.d(4834): Error: cannot implicitly convert expression (cast(int)this.pastLast - 1) of type int to inout(short)
test.d(5): Error: template instance std.range.iota!(short,short) error instantiating
...\dmd2\src\phobos\std\range.d(4834): Error: cannot implicitly convert expression (cast(int)this.pastLast - 1) of type int to inout(ushort)
test.d(6): Error: template instance std.range.iota!(ushort,ushort) error instantiating
test.d(7): Error: template std.range.iota does not match any function template declaration
...\dmd2\src\phobos\std\range.d(4717): Error: template std.range.iota cannot deduce template function from argument types !()(char,char)
Comment #1 by andrej.mitrovich — 2013-02-03T12:47:03Z
https://github.com/D-Programming-Language/phobos/pull/1107
I'd say this is a bug, not an enhancement.
However the last line where you use iota with chars is not part of my pull, I think that should be an enhancement (I really don't want to get dragged into another Unicode discussion with chars/wchars/dchars so I've left it alone).
Comment #2 by andrej.mitrovich — 2013-02-03T12:48:00Z
Tidied up the title to make it look nicer in the changelog.
Comment #3 by andrej.mitrovich — 2013-02-03T12:57:54Z
*** Issue 8585 has been marked as a duplicate of this issue. ***
Comment #4 by bearophile_hugs — 2013-02-03T14:05:42Z
(In reply to comment #2)
> Tidied up the title to make it look nicer in the changelog.
Thank you. I am not native English, so sometimes my titles are suboptimal.
> However the last line where you use iota with chars is not part of
> my pull, I think that should be an enhancement (I really don't want
> to get dragged into another Unicode discussion with
> chars/wchars/dchars so I've left it alone).
What's the problem with iota('a', 'f') ?
Comment #5 by github-bugzilla — 2013-02-03T16:29:58Z