Opportunity
Jesse Phillips
Jessekphillips+d at gmail.com
Tue Apr 9 19:30:41 PDT 2013
On Tuesday, 9 April 2013 at 16:54:30 UTC, Peter Alexander wrote:
> On Tuesday, 9 April 2013 at 15:50:11 UTC, Andrei Alexandrescu
> wrote:
>> Lack of generics makes it very tenuous to do meaningful work
>> on algorithms and their associated data structures.
>
> Why?
I think the answer to that is working on implementing an
algorithm to work on a data structure not provided by the
language can only reach as far as the type you implemented the
algorithm for. Thus the work done to implement that algorithm
wasn't very meaningful as it isn't reusable.
On a similar note. Earlier I was having a discussion with someone
who was stating, "The problem with the whole generics complaint
is that people tend to focus on Go's lack of generics to mean Go
lacks any safe polymorphism at all." He was quite aware "What Go
doesn't have is parametric polymorphism."
I was kind of worried that it would be impossible to specify a
different sort for a data type. I ended up writing some code to
sort a slice of Time[1]. I was glad to find out I was wrong, but
also very concerned with what I did find.
1. http://ideone.com/eVWfnk
- There is a built in function make which takes a type! That was
interesting.
- Data doesn't provide a default means to sort.
- I had to write the data access of the array!
- I also couldn't get the functions to take a slice of time,
instead I had to define a TimeSlice which was a slice of time.
Needless to say WTF! That was with a built in data structure, at
least I know it will work with any custom structure.
More information about the Digitalmars-d
mailing list