Messages in this thread | | | Date | Sun, 14 Nov 2010 09:51:08 +0100 | From | Stefan Richter <> | Subject | Re: [PATCH v6] Add generic exponentially weighted moving average (EWMA) function |
| |
KOSAKI Motohiro wrote: >>> Why do ewma_init() and ewma_add() return their first argument? They look >>> to me like they can be straight-forward void functions. >> You are right, for ewma_init() it does not make sense. >> >> For ewma_add() I think it does. This has been discussed before (e.g. >> http://linux.derkeiler.com/Mailing-Lists/Kernel/2010-10/msg09124.html). >> Some people might want to get the value when they add a sample by using >> ewma_get(ewma_add(&ewma, val)); > > ewma_add(&ewma, val); > ewma_get(&ewma); > > is enough simpler and cleaner. I don't oppse this :)
There are more candidate colors for the bike shed: :-) - an ewma_add_return could do what ewma_get(ewma_add(...)) is meant for, - or ewma_add itself could return the result.
BTW, isn't "get" more usually used as a prefix for these kinds of functions in kernel APIs? "get" as a suffix more often means "get a reference" alias increase reference count rather than "get the value". -- Stefan Richter -=====-==-=- =-== -===- http://arcgraph.de/sr/
| |