[Issue 4114] Support static arrays in some algorithms

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Aug 14 17:42:06 PDT 2011


http://d.puremagic.com/issues/show_bug.cgi?id=4114


Jonathan M Davis <jmdavisProg at gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |jmdavisProg at gmx.com
         Resolution|                            |WONTFIX


--- Comment #3 from Jonathan M Davis <jmdavisProg at gmx.com> 2011-08-14 17:42:00 PDT ---
Slicing static arrays works. In some cases, there may be issues, but in most
cases, it works. Most range-based functions don't alter the original range in
manner which would be of any risk to static arrays. Predicates don't usually
escape anything either. It would be a _highly_ abnormal predicate which did,
and I'd be worried about any predicate which did. Predicates for std.algorithm
functions are generally assumed not to have state which changes and usually
won't work right if they do. The greatest risk is if you try and return a range
from a range-based function which you passed a static array to. _That_ risks
leaks, but the programmer is just going to have to be careful about that.
There's no way to disallow the use of dynamic arrays which point to static
arrays.

Creating overloads for static arrays would result in needlessly copying them
(since static arrays are value types), and would further clutter std.algorithm,
increasing its maintenance cost. We're just not going to do anything which
treats static arrays special in order to work with range-based functions. If
you want to use a static array with a range-base function, then slice it and be
sure that you don't let the resulting range escape the scope of the static
array.

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


More information about the Digitalmars-d-bugs mailing list