View mode: basic / threaded / horizontal-split · Log in · Help
April 06, 2012
[Issue 7840] New: $ property for arrays
http://d.puremagic.com/issues/show_bug.cgi?id=7840

          Summary: $ property for arrays
          Product: D
          Version: D2
         Platform: All
       OS/Version: All
           Status: NEW
         Severity: enhancement
         Priority: P2
        Component: DMD
       AssignedTo: nobody@puremagic.com
       ReportedBy: bearophile_hugs@eml.cc


--- Comment #0 from bearophile_hugs@eml.cc 2012-04-05 18:05:40 PDT ---
This is a low-priority and low-importance "enhancement suggestion" (it's not
even an enhancement request because I am not sure if this is a good idea. I
will close it if you think it's a bad idea).

Currently you are allowed to use $ to denote array lengths inside their [],
like this:
arr[$ - 1]

The idea here is to extend the $ syntax as suffix too, something like this:


@property size_t __dollar(T)(in T[] a) pure nothrow {
   return a.length;
}
void main() {
   int[5] a;
   auto len = a.$;
}


This shortens the code, and this code isn't harder to understand because D
programmers already know that $ means the length of the array.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 17, 2013
[Issue 7840] $ property for arrays
http://d.puremagic.com/issues/show_bug.cgi?id=7840


yebblies <yebblies@gmail.com> changed:

          What    |Removed                     |Added
----------------------------------------------------------------------------
                CC|                            |yebblies@gmail.com


--- Comment #1 from yebblies <yebblies@gmail.com> 2013-01-17 13:56:38 EST ---
I would consider this a bad idea, but that's just me.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Top | Discussion index | About this forum | D home