Re: .NET generics & the .NET framework: not generic enough?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Daniel O'Connell [C# MVP] (onyxkirx_at_--NOSPAM--comcast.net)
Date: 07/18/04


Date: Sun, 18 Jul 2004 02:35:32 -0500


"Jay B. Harlow [MVP - Outlook]" <Jay_Harlow_MVP@msn.com> wrote in message
news:%2349uNcIbEHA.2944@TK2MSFTNGP11.phx.gbl...
> Daniel,
> I gave the link more for an example of an existing suggestion, not as a
> suggestion I specifically endorse.
>

Sorry, I didn't mean to be harsh. I'm just rather annoyed with the operator
thing. I think I've posted that same general reply a dozen times now.

> I like IArithmetic<T>, as it seems to be the "easier" route. (the KISS
> principal). If only Int32 implemented it ;-) also IArithmetic<T> is in
> keeping with IComparable<T>.
Ya, that would help termendously by helping to constrain generics to
primatives alone. I do wish there was a way to express that you want int,
uint, byte, sbyte, short, ushort, long, ulong, string, decimal, double or
float *only* in a generic. It'd help out *alot* in data situations where you
want to create classes that handle simple data. But, alas, that is a pipe
dream right now. IArithmetic wouldn't help with everything, but it'd make
numbers simpler.

>
> I agree that an actual "operator +" constraint may need to get too fancy
> to
> be useful, especially when you consider it needs to work across languages.
> But then again Microsoft has a lot of talented people working for them,
> and
> if we (the users) keep throwing it about in the publics, hopefully
> something
> usable can be created...
>
Well, I for one am not a huge fan of operator overloading in general, but it
is frustrating not to be able to perform basic mathematics with generics. It
certainly takes away the ability to *easily* do something like the stream in
STL, where the size type could be defined in the template.



Relevant Pages

  • Re: "Vector" Equivalent
    ... It still requires having to inherit and redeclare which is ... ANYWAY (and currently re-implement also - the suggestion eliminates the ... I am convinced that my suggestion is a good one (actually Loren's ... generics should be considered to address the need as you perceived it, ...
    (borland.public.delphi.non-technical)
  • Re: "Vector" Equivalent
    ... What I've suggested, inspired by Loren, is not generics - at leat I ... TListItem type, using my suggestion I can provide an Items property that ...
    (borland.public.delphi.non-technical)
  • Re: Operator overloading in C
    ... The specifications for that can be downloaded from: ... To provide some context for those who haven't been following this in comp.lang.c, I believe Jacob is advocating adding operator overloading to standard C, and thinks that the benefits of it far outweigh the downsides. ... He has made this suggestion a few times in comp.lang.c but the locals suggested that proposals for changing the C standard should be made here rather than there. ...
    (comp.std.c)
  • Re: .NET generics & the .NET framework: not generic enough?
    ... If you haven't you may want to submit a suggestion at: ... I was actually thinking of the Generic Delegate combined with an anonymous ... > hopes that .NET generics will be a powerful tool to design our programs ... > know them (including easy work-arounds we might be missing). ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Operator overloading in C
    ... To provide some context for those who haven't been following this in comp.lang.c, I believe Jacob is advocating adding operator overloading to standard C, and thinks that the benefits of it far outweigh the downsides. ... He has made this suggestion a few times in comp.lang.c but the locals suggested that proposals for changing the C standard should be made here rather than there. ... By the way, yes I am saying make the pointer constant, that is deliberate. ...
    (comp.std.c)