www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11779] New: pointer to slice is not an input range

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

           Summary: pointer to slice is not an input range
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: monarchdodra gmail.com


--- Comment #0 from monarchdodra gmail.com 2013-12-19 13:25:38 PST ---
As a rule thumb, when the type "S" is an input range, than so is "S*". Indeed,
all of "S's primitives" can also be called using a pointer, EG:
S* p;
p.popFront(); //OK!

This works for *all* input ranges... except for slices. This is because the
"slice range primitives" are actually non-member functions:
int[]* p;
p.popFront(); //DERP!
Error: template std.array.popFront does not match any function template
declaration

I think, to be consistent with the "emulate a member primitive", that the range
functions in std.array should also work on pointer to slice.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 19 2013
parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11779


Peter Alexander <peter.alexander.au gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |peter.alexander.au gmail.co
                   |                            |m


--- Comment #1 from Peter Alexander <peter.alexander.au gmail.com> 2014-02-08
12:13:20 PST ---
I don't think this can work with random access ranges. Pointers already define
opIndex, so it can't be forwarded to pointee range.

I think the opposite of this request should be implemented: pointers should
specifically *not* be ranges, ever.

(as an aside, I dislike how D uses . for pointer member access instead of ->,
it's a massive hack in my opinion, and really unnecessary since pointers are
rarely used in D).

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 08 2014