Thread overview
[Issue 6798] New: Integrate overloadings for multidimentional indexing and slicing
Oct 10, 2011
Kenji Hara
Oct 10, 2011
Kenji Hara
Apr 09, 2013
Denis Shelomovskij
October 10, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6798

           Summary: Integrate overloadings for multidimentional indexing
                    and slicing
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: k.hara.pg@gmail.com


--- Comment #0 from Kenji Hara <k.hara.pg@gmail.com> 2011-10-09 17:34:56 PDT ---
The following replacement has been proposed by issue 3474.

x[$-2, y[$-6, $-9], $-2]
// is translated to
// x.opIndex(x.opDollar!0 - 2,
//           y.opIndex(y.opDollar!0 - 6, y.opDollar!1 - 9),
//           x.opDollar!2 - 2)

Similarly, I propose the following replacement for the overloading mixture of indexing and slicing.

x[2..$, $-1, y[$-6, 0..$]]
// is translated to
// x.opIndex(x.opSlice!0(2, x.opDollar!0),
//           x.opDollar!1 - 1,
//           y.opIndex(y.opDollar!0 - 6, y.opSlice!1(0, y.opDollar!1)))

And additionally, I propose to merge slicing into indexing.

x[]
// is translated to
// x.opIndex()

After all, the indexing and slicing getter will be translated to
x.opIndex(...), and the setter will be translated to x.opIndexAssign(value,
...).
And also, opSlice and opSliceAssign would be unnecessary.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 10, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6798


bearophile_hugs@eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs@eml.cc


--- Comment #1 from bearophile_hugs@eml.cc 2011-10-09 19:55:28 PDT ---
So is this:

y[$-6, 0..$:2]


getting translated like this?

y.opIndex(y.opDollar!0 - 6, y.opSlice!1(0, y.opDollar!1, 2))


Strides/steps are sometimes useful in numerics code.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 10, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6798


Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch


--- Comment #2 from Kenji Hara <k.hara.pg@gmail.com> 2011-10-10 02:35:06 PDT ---
Posted pull request. https://github.com/D-Programming-Language/dmd/pull/443

(This does not contains stride syntax/overloading.)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 13, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6798



--- Comment #3 from bearophile_hugs@eml.cc 2011-10-13 13:02:20 PDT ---
There was a discussion thread about the idea of supporting a syntax like:

y[$-6, 0..$:2]

Don:

http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=146464

And in my opinion one of the last messages in that thread, by Robert Jacques, seals the topic. I think nice stride syntax will be useful for user-defined types:

http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=146533

Do you want me to open another enhancement request that asks just for the stride syntax?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 09, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=6798



--- Comment #4 from Denis Shelomovskij <verylonglogin.reg@gmail.com> 2013-04-09 18:42:42 MSD ---
What is the state of this issue and the pull?

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