EmbeddedRelated.com
Forums
Memfault State of IoT Report

MISRA new rule suggestion

Started by Rob June 20, 2005
Ok, I admit this is just a personal preference of mine but I just
wondered if anyone else felt the same way. So here comes the suggested
rule

"Never use characters that cannot be pronounced"

Here are some highly contrived examples:

(1) __loop. Well, how are you supposed to drop that into polite
conversation? What if you have another variable called loop. How do you
verbally differentiate between the two of them?

(2) time_left so how could you tell it apart from TimeLeft?

Is it me or do I seem to have a dislike of _'s ?

Rob wrote:
> Ok, I admit this is just a personal preference of mine but I just > wondered if anyone else felt the same way. So here comes the suggested > rule > > "Never use characters that cannot be pronounced" > > Here are some highly contrived examples: > > (1) __loop. Well, how are you supposed to drop that into polite > conversation? What if you have another variable called loop. How do you > verbally differentiate between the two of them? > > (2) time_left so how could you tell it apart from TimeLeft? > > Is it me or do I seem to have a dislike of _'s ? >
I think it would be better to disallow two identifiers whose only difference is by underscores, just like it's a bad idea to have separate identifiers distinguished only by small or capital letters. Thus "time_left" would be fine, as long as you don't also have a "TimeLeft", just as having "TimeLeft" and "timeLeft" would be a bad idea.
David Brown wrote:
> Rob wrote: > >> Ok, I admit this is just a personal preference of mine but I just >> wondered if anyone else felt the same way. So here comes the suggested >> rule >> >> "Never use characters that cannot be pronounced" >> >> Here are some highly contrived examples: >> >> (1) __loop. Well, how are you supposed to drop that into polite >> conversation? What if you have another variable called loop. How do you >> verbally differentiate between the two of them? >> >> (2) time_left so how could you tell it apart from TimeLeft? >> >> Is it me or do I seem to have a dislike of _'s ? >> > > I think it would be better to disallow two identifiers whose only > difference is by underscores, just like it's a bad idea to have separate > identifiers distinguished only by small or capital letters. Thus > "time_left" would be fine, as long as you don't also have a "TimeLeft", > just as having "TimeLeft" and "timeLeft" would be a bad idea.
(attack of the Style Nazis :) <rant> C'mon ... be flexible, solve *real* problems, and don't start long, contentious, useless threads. Also, be neat and consistent. If I never see another "Style Manual" it will be too soon. </rant> -- Michael N. Moran (h) 770 516 7918 5009 Old Field Ct. (c) 678 521 5460 Kennesaw, GA, USA 30144 http://mnmoran.org "So often times it happens, that we live our lives in chains and we never even know we have the key." The Eagles, "Already Gone" The Beatles were wrong: 1 & 1 & 1 is 1
Rob wrote:
> (1) __loop. Well, how are you supposed to drop that into polite > conversation?
"under-under-loop"
> (2) time_left so how could you tell it apart from TimeLeft?
"time-under-left" -- Dave Tweed

David Tweed wrote:
> Rob wrote: > > (1) __loop. Well, how are you supposed to drop that into polite > > conversation? > > "under-under-loop" > > > (2) time_left so how could you tell it apart from TimeLeft? > > "time-under-left" > > -- Dave Tweed
Following Mr pre-decremented Tweed's suggestion, I am going to have to start using the following _Milkwood _score _pass _pants Ian
On 20 Jun 2005 05:29:08 -0700, ian_okey@hotmail.com wrote:

> > >David Tweed wrote: >> Rob wrote: >> > (1) __loop. Well, how are you supposed to drop that into polite >> > conversation? >> >> "under-under-loop" >> >> > (2) time_left so how could you tell it apart from TimeLeft? >> >> "time-under-left" >> >> -- Dave Tweed > >Following Mr pre-decremented Tweed's suggestion, I am going to have to >start using the following > >_Milkwood
>_score
..well as _ is often called an "Underscore", that one could causeeven more confusion....
In article <42B6A867.38F35D8F@acm.org>, David Tweed <dtweed@acm.org>
writes
>Rob wrote: >> (1) __loop. Well, how are you supposed to drop that into polite >> conversation? > >"under-under-loop" > >> (2) time_left so how could you tell it apart from TimeLeft? > >"time-under-left" > >-- Dave Tweed
Captain Over, Captain Under, Captain Done? (apologise to Airplane part Deaux :-) -- \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ \/\/\/\/\ Chris Hills Staffs England /\/\/\/\/ /\/\/ chris@phaedsys.org www.phaedsys.org \/\/\ \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
In article <1119257507.051249.148300@g47g2000cwa.googlegroups.com>, Rob
<mr_horton@yahoo.com> writes
>Ok, I admit this is just a personal preference of mine but I just >wondered if anyone else felt the same way. So here comes the suggested >rule > >"Never use characters that cannot be pronounced" > >Here are some highly contrived examples: > >(1) __loop. Well, how are you supposed to drop that into polite >conversation? What if you have another variable called loop. How do you >verbally differentiate between the two of them? > >(2) time_left so how could you tell it apart from TimeLeft? > >Is it me or do I seem to have a dislike of _'s ? >
I will show the MISRA-C team tomorrow. We are half way through one of our 2 day meetings.... We need a diversion at tea time :-) -- \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ \/\/\/\/\ Chris Hills Staffs England /\/\/\/\/ /\/\/ chris@phaedsys.org www.phaedsys.org \/\/\ \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
On 20 Jun 2005 01:51:47 -0700, "Rob" <mr_horton@yahoo.com> wrote:

>Ok, I admit this is just a personal preference of mine but I just >wondered if anyone else felt the same way. So here comes the suggested >rule > >"Never use characters that cannot be pronounced" > >Here are some highly contrived examples: > >(1) __loop. Well, how are you supposed to drop that into polite >conversation? What if you have another variable called loop. How do you >verbally differentiate between the two of them? > >(2) time_left so how could you tell it apart from TimeLeft? > >Is it me or do I seem to have a dislike of _'s ?
Having variable names such as L00P, LO0P are much more of a problem than an underscore. Varaibles starting with an underscore should not be used in user apps in anycase. They are supposed to be for the compiler implementor. Regards Anton Erasmus
On 20 Jun 2005 01:51:47 -0700, "Rob" <mr_horton@yahoo.com> wrote:

>Ok, I admit this is just a personal preference of mine but I just >wondered if anyone else felt the same way. So here comes the suggested >rule
[...]
>Is it me or do I seem to have a dislike of _'s ?
It's just you. Actually, I think most of MISRA (and most other coding "standards") could be replaced with one simple rule: "Lint your d*mn code." Regards, -=Dave -- Change is inevitable, progress is not.

Memfault State of IoT Report