Re: Announcing CodeGear RAD Studio 2007



In article <46f08b71@xxxxxxxxxxxxxxxxxxxxxx>, David Clegg says...

I humbly apologise for attempting to help you in what I thought was a
genuine quest to determine where generics can be useful outside of the
oft quoted example of type safe containers.

And I humbly apologise for pointing out that the article you used as
reference did no such thing.


Your actions in this
sub-thread (and others as well) strongly suggest to me that you are
more interested in nit picking and fighting than actually finding out
if generics may be useful.

Quite the reverse, but the abject failure of anyone (so far) to provide
any such evidence, despite often thinking that they have done so, is
quite illuminating in and of itself.

I am reminded of The Emporers New Clothes....


I suspect your mind has already been made up
on this, so any example shown to you is then manipulated in such a way
as to support your current stance.

Give me an example that shows what you think it shows, then we can talk.

Your reference article thus far cited an example that it did not provide
and which would suffer numerous problems that even you seem to accept
make it a less than useful example.

The example it DID provide was in itself a good one, albeit clumsily
implemented - it SHOULD have shown a generic METHOD, not a generic TYPE,
since in the form in which it was presented it was arguably more
cumbersome and unwieldy to use than an overloaded function (and the
algorithm that it provided was hardly the sort of thing that would be
arduous or risky to repeat in overloaded methods as needed - the sort of
example, in other words, that shows how generics are a lazy mans tool,
not a genuine contribution to code quality/productivity).

Which is not to say that such an example does not exist or that such a
case cannot be made, just that this isn't it.


Also, the article didn't fully explore (or make the case for) the
benefits - and disadvantages - that accrue from using a generic
approach.

e.g. an array reverser might have hade a good example if approached
correctly.

How about an array copier?


In a generics based approach you would have to size a new array and copy
each member one item at a time from one array to the other.

In an overloaded approach you can exploit the fact that you are NOT
restricted to a type-agnostic approach in some cases. So for an integer
array, where you know that the array is 4 x array length bytes in size
you can allocate a chunk of memory and just CopyMemory() the entire
array in one go.


What about discussing the potential risk to productivity/code quality
that having a needlessly diverse array [sic] of approaches to any one
problem could lead to?

If there is no such risk, an exploration of how we can know that might
be useful.

--
JS
www.deltics.co.nz
.



Relevant Pages

  • Wasted Efforts (Parametric polymorphism?)
    ... And even if below solves problems that are solved in generics or templates, does that necessarily mean that we can't come up with a better solution.. ... astrarray = array of string; ... procedure add(const item: AnyType var arr: AnyTypeArray); ...
    (borland.public.delphi.non-technical)
  • Re: A question related to type casting
    ... Given that the distinction already had to be worked around (you couldn't put an int in a List before Java 5), the added complexity would end up being rather pointless. ... Lack of support for value types means more than just the execution overhead of the boxing. ... For example, ArrayList<T> stores the elements in an array of type T. But, there's no way for the class to use an array of ints; it has to be Integer, with each array element a reference to a boxed int, and of course for there to be a separately allocated Integer instance for each non-null array element. ... You're correct that it would have been more complex to support generics in a reifiable way. ...
    (comp.lang.java.programmer)
  • Re: Generic procedures and their parameters
    ... Integer belong to Ordered'Class. ... It's a shaky ground. ... array types based on exactly same combination of index and element types. ... coincidence that "other languages" drift towards supporting generics, ...
    (comp.lang.ada)
  • Pointer to a generic type parameter
    ... I'm new in VC++ and have a question to generics. ... which contains an array of the generic type. ... I wanted to creat a class member which represents the pointer to the ...
    (microsoft.public.dotnet.languages.vc)
  • Re: generics and arrays and multi-class collections
    ... java.util.ArrayList uses an array of Object to store its ... The cast generates an unchecked warning. ... Wisdome is "use Java generics only at its shallowest". ...
    (comp.lang.java.programmer)