Re: #qcx CAT control #qcx

jjpurdum
 

No, I realize that. Programming is very much a personal endeavor and much of my predilection comes from teaching this stuff while I was at Purdue. You would not believe the variance you see in coding style even when the assignment is the same for all of the students. The best I could do was point out the options.

Jack, W8TEE

On Saturday, November 30, 2019, 11:52:51 AM EST, Roger Hill <rhill@...> wrote:


Cheers Jack. Not grumbling at all...to each his own.

Roger

On 30 Nov 2019, at 16:50, "jjpurdum via Groups.Io" <yahoo.com@groups.io target=_blank>jjpurdum=yahoo.com@groups.io> wrote:
I think it depends on what you're used to seeing. If I see a memset() call, I can figure out what it's doing much faster than I can if I have to read the 3 for loop expressions, and the statements controlled by that loop. To me, this is not "enhanced" or "elegant" code at all. It simply reflects familiarity with the System V Standard C library, of which the mem*() family of functions have been a part of for about 40 years. Indeed, a good part of becoming a C programmer is knowing what's available in the vast selection of libraries. As far as performance, some of those frequently-used library functions are written in hand-tweaked assembler and I know I cannot write it more efficiently. Given that, why waste time writing, testing, and debugging a section of code when you know it's already been done for you?

So, where you need to study what memset() does, I have to study what a multi-line for loop does. If you had been using memset() for 40 years, I think you, too, would find it takes more time to understand the for loop code than the lone memset() call, especially when you know the third parameter simply sets the byte limit for the initialization.

Jack, W8TEE

On Saturday, November 30, 2019, 11:12:09 AM EST, Roger Hill <rhill@...> wrote:


Yeah. After 50 years of coding in many languages, I still would prefer to have to maintain the 'less good' for loop.. it much more obvious what it is doing.

The fancy version might be more elegant or whatever but I would have to read it several times to decide what it was doing.

Roger

On 30 Nov 2019, at 16:07, Michael Welle < mwe012008@...> wrote:
Hello,

"jjpurdum via Groups.Io" <jjpurdum=yahoo.com@groups.io> writes:

Opps! Forgot to multiple the elements by the size:
    memset(myArray, 0, ELEMENTS(myArray) * sizeof(myArray[0]) );

with the macro expanded this results in

memset(myArray, 0, (sizeof(myArray) / sizeof(myArray[0]))*sizeof(myArray[0]));

Well, with optimisation enabled, the compiler can generate compact machine
code out of that. But as a human code reviewer I would question that and
would expect to find other interesting things in the code ;). I think
producing correct code is a complicated task and we should strive for
correct code first and then for beautiful or otherwise 'enhanced' code.

Regards
hmw



Join QRPLabs@groups.io to automatically receive all group messages.