www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9447] New: iota should generate char intervals too

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9447

           Summary: iota should generate char intervals too
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: rejects-valid
          Severity: enhancement
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc


--- Comment #0 from bearophile_hugs eml.cc 2013-02-03 18:05:18 PST ---
Spinoff of Issue 8920


import std.range: iota;
void main() {
    foreach (i; iota('a', 'f')) {}
}


DMD 2.062alpha gives:

temp.d(3): Error: template std.range.iota does not match any function template
declaration. Candidates are:
...\dmd2\src\phobos\std\range.d(5107):        std.range.iota(B, E, S)(B begin,
E end, S step) if ((isIntegral!(CommonType!(B, E)) || isPointer!(CommonType!(B,
E))) && isIntegral!(S))
...\dmd2\src\phobos\std\range.d(5192):        std.range.iota(B, E)(B begin, E
end) if (isFloatingPoint!(CommonType!(B, E)))
...\dmd2\src\phobos\std\range.d(5199):        std.range.iota(B, E)(B begin, E
end) if (isIntegral!(CommonType!(B, E)) || isPointer!(CommonType!(B, E)))
...\dmd2\src\phobos\std\range.d(5260):        std.range.iota(E)(E end)
...\dmd2\src\phobos\std\range.d(5267):        std.range.iota(B, E, S)(B begin,
E end, S step) if (isFloatingPoint!(CommonType!(B, E, S)))
temp.d(3):        ... (1 more, -v to show) ...
...\dmd2\src\phobos\std\range.d(5107): Error: template std.range.iota cannot
deduce template function from argument types !()(char,char)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 03 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9447


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich gmail.com


--- Comment #1 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2013-02-04
10:15:42 PST ---
The reason I mentioned Unicode in Issue 8920 is because I'm unsure whether
simply incrementing the integral value of a character will produce a valid
character (valid in how the Unicode standard defines it). 

For ASCII 'a'--'z' it's likely not an issue, but I'm thinking about the case of
wchars and dchars. E.g. we would probably have to use isValidDchar.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 04 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9447


Jonathan M Davis <jmdavisProg gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jmdavisProg gmx.com


--- Comment #2 from Jonathan M Davis <jmdavisProg gmx.com> 2013-02-04 10:48:33
PST ---
It is definitely _not_ the case that adding 1 to a wchar or dchar will
necessarily result in a valid value. In both of them, there's a block in the
middle which is invalid. Just like at the implementation of isValidDchar.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 04 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9447



--- Comment #3 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2013-02-04
10:57:34 PST ---
(In reply to comment #2)
 It is definitely _not_ the case that adding 1 to a wchar or dchar will
 necessarily result in a valid value. In both of them, there's a block in the
 middle which is invalid. Just like at the implementation of isValidDchar.

Is this the only restriction though? If that's so, it should be easy to implement this feature with a single runtime check to verify the range doesn't go over the invalid block. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 04 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9447


monarchdodra gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |monarchdodra gmail.com


--- Comment #4 from monarchdodra gmail.com 2013-07-26 00:12:08 PDT ---
(In reply to comment #3)
 (In reply to comment #2)
 It is definitely _not_ the case that adding 1 to a wchar or dchar will
 necessarily result in a valid value. In both of them, there's a block in the
 middle which is invalid. Just like at the implementation of isValidDchar.

Is this the only restriction though? If that's so, it should be easy to implement this feature with a single runtime check to verify the range doesn't go over the invalid block.

I think that is a bad idea. We should keep it simple: User asks to iterate over xchars of values low to high, and that is all we should return. When it comes to wchars or dchars, the notion of "invalid" is really in the eye of the beholder anyway. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 26 2013