[Issue 7520] opDollar undocumented
http://d.puremagic.com/issues/show_bug.cgi?id=7520 --- Comment #4 from github-bugzi...@puremagic.com 2013-10-26 06:55:56 PDT --- Commit pushed to master at https://github.com/D-Programming-Language/dlang.org https://github.com/D-Programming-Language/dlang.org/commit/2b6ff78b3d5148f9a3a9968fc1437a2a73d4fc45 Merge pull request #292 from quickfur/opdollar Document opDollar (issue 7520) -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 7520] opDollar undocumented
http://d.puremagic.com/issues/show_bug.cgi?id=7520 Kenji Hara k.hara...@gmail.com changed: What|Removed |Added Status|NEW |RESOLVED Resolution||FIXED -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 7520] opDollar undocumented
http://d.puremagic.com/issues/show_bug.cgi?id=7520 hst...@quickfur.ath.cx changed: What|Removed |Added Keywords||pull --- Comment #3 from hst...@quickfur.ath.cx 2013-03-02 13:05:22 PST --- https://github.com/D-Programming-Language/d-programming-language.org/pull/292 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 7520] opDollar undocumented
http://d.puremagic.com/issues/show_bug.cgi?id=7520 hst...@quickfur.ath.cx changed: What|Removed |Added CC||hst...@quickfur.ath.cx --- Comment #2 from hst...@quickfur.ath.cx 2013-02-28 20:12:58 PST --- I've used opDollar in some of my code; it appears to work like this: obj[$] gets lowered to obj.opIndex(obj.opDollar!0); obj[1,$] gets lowered to obj.opIndex(1, obj.opDollar!1); obj[1,2,$] gets lowered to obj.opIndex(1, 2, obj.opDollar!2); and so on. The $ is recognized in subexpressions as well, so: obj[1, func(2,$), 3] gets lowered to obj.opIndex(1, func(2, obj.opDollar!1), 3). In other words, the compile-time argument of opDollar is the index of position it appears in, in the arguments of the indexing operator. Unfortunately, it appears that only opDollar!0 is implemented for opSlice (besides, slicing syntax currently does not support multiple ranges). aside But even with the current opIndex and opDollar, one can hack around the lack of multidimensional opSlice by defining a custom range type, say: struct Range { int start,end; }, then you can overload opIndex to recognize pseudo-slicing syntax: obj[Range(1,2), Range(2,$)] gets translated to obj.opIndex(Range(1,2), Range(2,obj.opDollar!1)), so you just have to define: auto opIndex(Range r1, Range r2), and you can have pseudo-multidimensional slicing. One can even use variadic parameters to handle a mix of slicing and indexing: auto opIndex(R...)(R args) { foreach (arg; args) { static if (typeof(arg) : Range) { // slice this dimension } else if (typeof(arg) : indexType) { // index this dimension } } } The $'s are correctly translated to opDollar!i based on their position i in the [] operator, so this will correctly handle things like obj[$-1, Range(0,$-1)], obj[Range(0,$), 10], etc.. /aside -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 7520] opDollar undocumented
http://d.puremagic.com/issues/show_bug.cgi?id=7520 Andrej Mitrovic andrej.mitrov...@gmail.com changed: What|Removed |Added CC||andrej.mitrov...@gmail.com See Also||http://d.puremagic.com/issu ||es/show_bug.cgi?id=3474 --- Comment #1 from Andrej Mitrovic andrej.mitrov...@gmail.com 2013-02-04 14:14:17 PST --- The feature was implemented in Issue3474 by https://github.com/D-Programming-Language/dmd/pull/442 I suggest Don and/or Kenji get on this since they know exactly how opDollar works. Apparently it can be a template, but I know very little about this. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---