473,427 Members | 1,773 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,427 software developers and data experts.

mnemonic

Hi all,

Is there any mnemonic for remembering C precedence rules????

I have just coined the word TUBSREBLCAC

where T --- top level operators
U ---- unary operators
B ----- binary operators
S ------ shift operators
R------- relational operators
E ------ equality operators
B ------- bitwise operators
L ------- logical operators
C ----- conditional operators
A ----- assignment operators
C ------ comma operator

how good is this mnemonic

or is there any simple mnemonic such as

"How I want a sweetened drink of course after the heavy lectures
involving quantum mechanics" which is mainly used by math pros for
remembering Pi value(3.14195265358979)

Nov 1 '07
60 3768
Richard wrote:
Tor Rustad <to********@hotmail.comwrites:
[...]
>A debugger isn't always the best tool for the job. How many race
conditions have you tracked down via a debugger?

I would not use a debugger to unblock the u-bend under my kitchen sink
either. But I would use it to catch errors in a real world C program ....
You sounds more like a junior programmer, maintaining a prototype.

--
Tor <bw****@wvtqvm.vw | tr i-za-h a-z>
Nov 4 '07 #51
Tor Rustad <to********@hotmail.comwrites:
Richard wrote:
>Tor Rustad <to********@hotmail.comwrites:

[...]
>>A debugger isn't always the best tool for the job. How many race
conditions have you tracked down via a debugger?

I would not use a debugger to unblock the u-bend under my kitchen sink
either. But I would use it to catch errors in a real world C program ....

You sounds more like a junior programmer, maintaining a prototype.
Well, I can say with some authority I clearly have much better and more
detailed knowledge of how to use a debugger for what it was intended to
do than you. Why you want to throw in straw men about the minority of
cases where a debugger might not be useful is quite beyond me. No one
described it as a "single solution for all cases".

From your rather "high level perch" I wonder why you are even discussing
debuggers since you are clearly too clever and senior to have to use one.

But thank you for the kind words regardless :-;
Nov 4 '07 #52
On Nov 4, 4:15 pm, Richard <rgr...@gmail.comwrote:
>
The view of some of the regulars here is quite astonishing and makes me
wonder how many have really worked in Industry on large code bases
maintained by multiple programmers across the world.
Now there's a sentiment I agree with entirely, though I suspect we're
thinking of different groups of regulars.
Nov 4 '07 #53
Richard <rg****@gmail.comwrote:
Tor Rustad <to********@hotmail.comwrites:
Serve Lau wrote:
"James Kuyper" <ja*********@verizon.netwrote in message
That's a weird interpretation! The quote is about debugging, not
debuggers. It's about the importance of writing code so it can be
debugged, which implies that debugging is important too, not that
it's unnecessary.

Who's saying this?

its in this thread.

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are, by
definition, not smart enough to debug it." - Brian W. Kernighan
Nope, Kernighan refer to debugging, which is a process not limited to
running a program in a debugger.

Of course it isn't. But it would be fairly ridiculous to suggest that
any form of debugging an existing code base is NOT done with a
"debugger" of some description.
It would be ridiculous. However, for the wise, "debugger" means
"programmer who finds and removes bugs", and not "program which steps
through another program". The former _may_ use the latter, but by no
means has to.

Richard
Nov 5 '07 #54
On 3 Nov, 15:09, Richard <rgr...@gmail.comwrote:
Tor Rustad <tor_rus...@hotmail.comwrites:
Serve Lau wrote:
"James Kuyper" <jameskuy...@verizon.netwrote in message
news:Al%Wi.6919$9N6.487@trnddc03...
>That's a weird interpretation! The quote is about debugging, not
debuggers. It's about the importance of writing code so it can be
debugged, which implies that debugging is important too, not that
it's unnecessary.
>Who's saying this?
its in this thread.
"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are, by
definition, not smart enough to debug it." - Brian W. Kernighan
debugging != using a debugger

this keeps on being said...

Nope, Kernighan refer to debugging, which is a process not limited to
running a program in a debugger.

Of course it isn't. But it would be fairly ridiculous to suggest that
any form of debugging an existing code base is NOT done with a
"debugger" of some description.
this is just silly. You're claiming a debugger is essential to
debugging
therefore if someone is debugging they are using a debugger. Make your
mind up.

A debugger is a special purpose program that is attached to a running
program
(or used to analyse a "core" dump) to aid in finding bugs in programs.

There are other ways to find bugs.

People who advocate littering code with
printfs are plain wrong IMO.
well depending what you mean by "littering" and "printf". My programs
typically write to log files. When Things Go Wrong the logfile at
least tells you
what the program was *trying to do. This sometimes happens on a
different
continent from my current location...

Yes, it might have its uses occasionally,
but any changing of the code to "debug" is generally considered a bad
thing.
"generally"?

From some of the comments I read here, I often wonder if the people
knocking debuggers have any idea whatsoever of just what they are, how
they work and the results they can achieve.
I use debuggers sometimes. I just don't think they are always useful.

One of my favorite uses of a debugger is simply to step through code to
get a feel for the control flow.
now this I find strange. Debugging is fixing faults. Why would you
step through the program at random (or is there a purpose?). The
programs I deal
with have soft RT requirements. If you start single stepping then the
program
looses data, drops comms links and fails to do things on time. They
are also
large. Stepping through the code "to get a feel for the control flow"
sounds odd.

Maybe this *is* an age thing.

Ability to step over calls and just
examine the returned data etc is much easier than "imagining" it by
reading code no matter how well and clearly that code is written and
annotated.
well I'll do that if I'm stuck. And debuggers are handy after crashes.
But not all bad things crash the program.

I have to deal with bugs where debuggers are not available. In fact
where
I am not even present.

Programs that record what tehya re doing are handy.
--
Nick Keighley
Nov 5 '07 #55
Nick Keighley <ni******************@hotmail.comwrites:
On 3 Nov, 15:09, Richard <rgr...@gmail.comwrote:
>Tor Rustad <tor_rus...@hotmail.comwrites:
Serve Lau wrote:
"James Kuyper" <jameskuy...@verizon.netwrote in message
news:Al%Wi.6919$9N6.487@trnddc03...
>>That's a weird interpretation! The quote is about debugging, not
debuggers. It's about the importance of writing code so it can be
debugged, which implies that debugging is important too, not that
it's unnecessary.
>>Who's saying this?
>its in this thread.
>"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are, by
definition, not smart enough to debug it." - Brian W. Kernighan

debugging != using a debugger

this keeps on being said...
Yes, by me too.
>
Nope, Kernighan refer to debugging, which is a process not limited to
running a program in a debugger.

Of course it isn't. But it would be fairly ridiculous to suggest that
any form of debugging an existing code base is NOT done with a
"debugger" of some description.

this is just silly. You're claiming a debugger is essential to
debugging
therefore if someone is debugging they are using a debugger. Make your
mind up.
A debugger of some description.
>
A debugger is a special purpose program that is attached to a running
program
(or used to analyse a "core" dump) to aid in finding bugs in programs.

There are other ways to find bugs.
Yes. We explored that a lot in the thread.
>
>People who advocate littering code with
printfs are plain wrong IMO.

well depending what you mean by "littering" and "printf". My programs
typically write to log files. When Things Go Wrong the logfile at
least tells you
what the program was *trying to do. This sometimes happens on a
different
continent from my current location...
None of which has anything to do with why debugging is not a good thing.
>
>Yes, it might have its uses occasionally,
but any changing of the code to "debug" is generally considered a bad
thing.

"generally"?
Yes. Generally.
>
>From some of the comments I read here, I often wonder if the people
knocking debuggers have any idea whatsoever of just what they are, how
they work and the results they can achieve.

I use debuggers sometimes. I just don't think they are always useful.
No. But generally they are. Its why they were invented.
>
>One of my favorite uses of a debugger is simply to step through code to
get a feel for the control flow.

now this I find strange. Debugging is fixing faults. Why would you
step through the program at random (or is there a purpose?). The
Yes there is a purpose. Reread the sentence - it is clear enough. To
step through the code to understand the program flow. The ability to
force logic conditions to step through less likely states is obviously a
boon to the investigative programmer. Debugging code is easier with a
knowledge of how it is constructed and runs.
programs I deal
with have soft RT requirements. If you start single stepping then the
program
looses data, drops comms links and fails to do things on time. They
are also
large. Stepping through the code "to get a feel for the control flow"
sounds odd.
So why mention it. Not everyone is RT.
>
Maybe this *is* an age thing.
I have no idea what you mean. The great majority of SW is not RT and a
debugger and debugging and associated techniques are not rocket science
and bring a lot to the table.
>
>Ability to step over calls and just
examine the returned data etc is much easier than "imagining" it by
reading code no matter how well and clearly that code is written and
annotated.

well I'll do that if I'm stuck. And debuggers are handy after crashes.
But not all bad things crash the program.
No one said they did. But a debugger can halt a program using predefined
watch conditions. Makes it far easier to locate the problems. Even in RT systems.
>
I have to deal with bugs where debuggers are not available. In fact
where
I am not even present.

Programs that record what tehya re doing are handy.
Yes. And this is a form of debugging.
Nov 5 '07 #56
On 1 Nov, 20:58, Julienne Walker <happyfro...@hotmail.comwrote:
On Nov 1, 4:43 pm, vipvipvipvipvip...@gmail.com wrote:
Parentheses can be annoying and useless in code.

They can be, if you use them abusively. On the other hand, *lack* of
parentheses can be annoying and useless in code for the same reason.
The solution is to learn operator precedence.

Perhaps *you* have perfect memory, but *I* don't. I'd rather remember
a simple guideline than a slew of rules, because to be perfectly
frank, I have better things to spend my few remaining brain cells
on. :-)
Indeed. In fact many moons ago I used the Watcom compiler(cant recall
what version... may have been 9 or 10) on QNX4.0 and the compiler was
actually non compliant with regard to the precedence rules so using
parentheses... since that experience my little brqain is unable to
revert to remembering the rules.

Nov 5 '07 #57
Richard <rg****@gmail.comwrites:
Nick Keighley <ni******************@hotmail.comwrites:
[...]
>this is just silly. You're claiming a debugger is essential to
debugging therefore if someone is debugging they are using a
debugger. Make your mind up.

A debugger of some description.
That sentence no verb.

Are you saying that debugging must always involve "a debugger of some
description"? If so, you're using the word "debugger in a much more
inclusive sense than I've ever seen. Please clarify.

If I happen to correct a flaw in a program by adding examining the
source code and adding temporary printf calls, I'm not using a
debugger (unless I *am* the debugger).

[...]
>well depending what you mean by "littering" and "printf". My
programs typically write to log files. When Things Go Wrong the
logfile at least tells you what the program was *trying to do. This
sometimes happens on a different continent from my current
location...

None of which has anything to do with why debugging is not a good thing.
Huh? Who ever said that debugging is not a good thing? Unless you're
using the word "debugging" specifically to mean using a source-level
debugger (such as gdb), then your statement makes no sense as far as I
can tell.

[...]

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
Looking for software development work in the San Diego area.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Nov 5 '07 #58
"Richard" <rg****@gmail.coma écrit dans le message de news:
ob************@news.individual.net...
Note : of course it is better to get it right first time. But in the
real world there will always be bugs.

2nd note : if a system crashes I can guarantee that i can debug it to
the point of the crash quicker than you can read and understand 500000
lines of C code and run it through in your head with all possible data
input and come to a guess at where it might crash .....
That may well be, but reading the 500000 lines will undoubtedly unearth
hundreds of other bugs, some of which would crash the system in even lesser
appropriate times.

--
Chqrlie.
Nov 7 '07 #59
"Ben Pfaff" <bl*@cs.stanford.edua écrit dans le message de news:
87************@blp.benpfaff.org...
Keith Thompson <ks***@mib.orgwrites:
>"Debugging" doesn't mean "using a debugger".

I'd say that about half of my bugs I find with printf. Another
half, I find with valgrind. Another 5% are made obvious with
"git bisect". The last 10%, I find with a traditional debugger.
My experience gives similar results.
I should also mention the 50% or more that are caught at typing time by
using proper editing tools with syntax coloring, automatic indentation,
brace balancing, completion... and the other 50% detected at code review
time.
But for reproducible crashes and endless loops, the debugger is indeed a
very effective tool.

--
Chqrlie
Nov 7 '07 #60
"Charlie Gordon" <ne**@chqrlie.orgwrites:
"Ben Bacarisse" <be********@bsb.me.uka écrit dans le message de news:
87************@bsb.me.uk...
>aa*****@gmail.com writes:
>>Is there any mnemonic for remembering C precedence rules????

Not that I know, but here are some thing that help me remember:
<snip>
>Everyone know that * binds more tightly than +, so just remember that
&& and & are the Boolean and bit-wise analogues of multiplication
whereas || and | are the analogues of +. I.e. && binds tighter
than || and & beats |. (Many maths notations use AB or A×B to mean A
and B.)

While this is a good analogy, it may be misleading because & binds less than
+
I suppose it might. It helps only for the pairs * and +, && and ||, &
and |.

<snip>
>This covers the vast majority of common cases. I also like to
remember that you can assign a conditional ('index += up ? 1 : -1' is
my canonical example), but you can't shift by an arithmetic expression
('x >(32 - bits)' requires the parentheses).

No, it does not: >binds less than + and -, but it is certainly a good idea
to use parentheses to make your intent clear for both yourself and the next
person reading the code.
Good spot. Don't know where I got that from. For some reason I
always bracket these and that must have lodged in my mind as being
required, but of course it is not.

--
Ben.
Nov 7 '07 #61

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Jonathan N. Little | last post by:
When doing a final check on my stylesheets the CSS Validator flag lines like this one as an error: ADDRESS A { color: gold; } Error is: # Line: 31 Context : ADDRESS A Invalid number :...
1
by: Lex | last post by:
I have a c# app that has a OwnerDrawn menu items. Is there and easy way to use DrawString to draw the underline under the mnemonic character? BTW - I figured out how to detected if we should...
162
by: techievasant | last post by:
hello everyone, Iam vasant from India.. I have a test+interview on C /C++ in the coming month so plz help me by giving some resources of FAQS, interview questions, tracky questions, multiple...
3
by: Grant | last post by:
Gday, My form has a text box and a label. The label is next to the textbox and has a mnemonic set for the first letter. My question is how to highlight the textbox when the user selects the...
0
by: Valerie Hough | last post by:
I have derived a class from MenuItem so that I can associate IDs of my choosing with each item (a la C++). I have created a ContextMenu in the constructor of an owner draw list box and added a...
3
by: Donal Kelly | last post by:
hi, I'm building a GUI in C# and I want the buttons to have a mnemonic character attached to the button. I cannot seem to do this in C#, where it was very simple to do in Visual C++. Thanks,...
0
by: Raith | last post by:
I have a form with various mnemonic (accellerator) keys set up, they all work fine except the password box ("&Password"). Is this perhaps because that's a default for Print? Is there a way to get...
39
by: jacob navia | last post by:
Mnemonic means trying to remember. Mnemonic means making annotations that remind you. Speaking about mnemonic I saw this message. Tor Rustad wrote: One of the problems with old people is...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.