std.array suggestion (version 2)

Derek Parnell derek at psych.ward
Sun Mar 19 16:07:00 PST 2006


On Sun, 19 Mar 2006 22:25:55 +0000, Oskar Linde wrote:

> Hello,
> 
> I've been working a bit more on my std.array suggestion in
> http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D/35008
> and have made some changes to the specification. 

Thanks Oskar. This is a great idea.

 
> I have some open issues:
> 
> 1. max/min on empty arrays
>  max/min are undefined on empty arrays. I see three options:
> 
>  a) return something, i.e T.min/max or T.init.
>  b) use an in contract asserting the array is non-empty
>  c) throw EmptyArrayException
> 
>  - a) doesn't feel very robust. b) seems to be the most D-ish.

Of course, 'in' contracts are stripped out in -release editions so one can
never rely on them catching empty arrays.
 
> 2. Naming of in-place functions
>  my current suggestion is doMap(), doSort(), etc. Other suggestions are
>  mapInPlace() and inPlaceMap(), but I find them a bit to wordy.

Any name will do if its documented well enough and consistent. But maybe
MapIt(), and SortIt()  ;-)
 

> Here is the full list of function definitions:

Is a 'merge' routine useful? I know it could be done with a join() then
sort(), but a merge might be able to optimize the behaviour.
 

-- 
Derek
(skype: derek.j.parnell)
Melbourne, Australia
"Down with mediocracy!"
20/03/2006 10:59:52 AM



More information about the Digitalmars-d mailing list