Click here to Skip to main content

Welcome to the Lounge

   

For lazing about and discussing anything in a software developer's life that takes your fancy.
The Lounge is rated PG. If you're about to post something you wouldn't want your kid sister to read then don't post it. No flame wars, no abusive conduct and please don't post ads.

Technical discussions are welcome, but if you need specific help please use the programming forums.


 
GeneralRe: WHats Kortrijk in Belgium like? [modified] PinmemberJimmyRopes9-Feb-14 8:09 
GeneralRe: WHats Kortrijk in Belgium like? [modified] PinmemberErudite_Eric9-Feb-14 8:54 
GeneralRe: WHats Kortrijk in Belgium like? PinprofessionalV.9-Feb-14 11:06 
GeneralRe: WHats Kortrijk in Belgium like? PinmemberErudite_Eric11-Feb-14 1:16 
GeneralRe: WHats Kortrijk in Belgium like? PinprofessionalV.11-Feb-14 3:08 
GeneralRe: WHats Kortrijk in Belgium like? Pinmember d@nish 9-Feb-14 19:55 
GeneralRe: WHats Kortrijk in Belgium like? PinmemberErudite_Eric9-Feb-14 22:01 
GeneralI hate it when I am too clever for my own good... PinprotectorOriginalGriff9-Feb-14 5:59 
So, I'm doing some analysis code, and I need a couple of moving averages - one over the whole sample, one over the last 30 samples, and one over the last ten samples.
 
Now, I don't fancy doing that in SQL, so I'm doing it in C#, and I decide the obvious thing to do is create a MovingAverage class that you Add samples to, and it sorts itself out. Easy peasy.
 
So I knock up the class framework, and the code that will use it, and then go back to fill in the class. And decide to make it generic because hey, I might want to use it again. Change everything to use generics - easy - and off we go...except...you can't sum generics, because they are based on object which doesn't implement arithmetic operators. And you can't restrict generics to classes that support arithmetic either...
 
So either I restrict it to just primitive types (int, double, blah blah blah) or I drop the whole idea...and you can't use primitive types as generic constraints...and it wouldn't work if you could, because primitive arithmetic is implemented via static inline functions at compile time, so you couldn't use 'em in a generic if you wanted to!
 
So...change it back Griff, change it all back... D'Oh! | :doh:
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)

GeneralRe: I hate it when I am too clever for my own good... PinmemberPIEBALDconsult9-Feb-14 6:05 
GeneralRe: I hate it when I am too clever for my own good... PinprotectorOriginalGriff9-Feb-14 6:17 
GeneralRe: I hate it when I am too clever for my own good... PinmemberPIEBALDconsult9-Feb-14 6:57 
GeneralRe: I hate it when I am too clever for my own good... PinprotectorOriginalGriff9-Feb-14 7:36 
GeneralRe: I hate it when I am too clever for my own good... Pinmemberharold aptroot9-Feb-14 6:33 
GeneralRe: I hate it when I am too clever for my own good... PinprotectorOriginalGriff9-Feb-14 6:44 
GeneralRe: I hate it when I am too clever for my own good... PinprofessionalKornfeld Eliyahu Peter9-Feb-14 7:38 
GeneralRe: I hate it when I am too clever for my own good... PinmemberPIEBALDconsult9-Feb-14 7:44 
GeneralRe: I hate it when I am too clever for my own good... PinprofessionalKornfeld Eliyahu Peter9-Feb-14 8:02 
GeneralRe: I hate it when I am too clever for my own good... PinmemberPIEBALDconsult9-Feb-14 8:07 
GeneralRe: I hate it when I am too clever for my own good... PinprofessionalKornfeld Eliyahu Peter9-Feb-14 8:18 
GeneralRe: I hate it when I am too clever for my own good... PinprofessionalJörgen Andersson9-Feb-14 10:07 
GeneralRe: I hate it when I am too clever for my own good... PinprofessionalKornfeld Eliyahu Peter9-Feb-14 10:22 
GeneralRe: I hate it when I am too clever for my own good... PinprofessionalJörgen Andersson9-Feb-14 10:49 
GeneralRe: I hate it when I am too clever for my own good... PinprofessionalKornfeld Eliyahu Peter9-Feb-14 10:53 
GeneralRe: I hate it when I am too clever for my own good... PinprofessionalJörgen Andersson9-Feb-14 11:10 
GeneralRe: I hate it when I am too clever for my own good... PinprofessionalBrisingr Aerowing9-Feb-14 7:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web02 | 2.8.141223.1 | Last Updated 27 Dec 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid