Why I (Still) Won't Use D

Sean Kelly sean at invisibleduck.org
Thu Mar 27 18:25:14 PDT 2008


== Quote from Walter Bright (newshound1 at digitalmars.com)'s article
> Michiel Helvensteijn wrote:
> > By hard-coding certain behaviors in the core language, you've taken away the
> > freedom of the programmer to choose these hirself. Like the growth-rate of
> > dynamic arrays. Or the sorting algorithm used by the .sort property.
> See Andrei's sort routines in std.algorithms. I don't think user
> extensibility is crippled at all.

I very much agree.  See tango.core.Array for another set of algorithms specifically
meant to extend the utility of built-in arrays:

http://www.dsource.org/projects/tango/docs/current/tango.core.Array.html

Since arrays already have the nifty trick where functions accepting them as the
first argument can be used via the property syntax, the built-in arrays are far
more flexible than any library type.  The Tango Array module has basically every
routine in <algorithm> plus a good number more, and the usage is specifically
catered to work with slices.  So you can do things like:

auto buf = "hello world";
printf( "The slice up to 'el' in %.*s is: %.*s\n", buf, buf[0 .. buf.find( "el" )] );

std::equal_range can be duplicated by:

buf[buf.lbound( 'e' ) .. buf.ubound( 'e' )]; // slice of lower to upper bound

etc.  The combination of good built-in arrays, the property syntax, and slicing
makes for a top-notch combination.  The <algorithm> stuff in C++ looks horrid
by comparison.


Sean



More information about the Digitalmars-d mailing list