I have a function that runs through a two dimensional array several times.
01 x=map->X;
02 do
02 {
04 y=map->Y;
05 do
05 {
06 stuff();
07
08 }while (y);
09 x--'
10 }while(x);
Would it be considered good or bad form to #define lines 01-05 as
something like START_MAP_LOOP and lines 07-10 as END_MAP_LOOP?
In processing these maps I have to go over them over and over again and
this would seriously reduce the size of the source files and make them
easier to read.
--
Mark Healey
marknews(at)healeyonline(dot)com
May 14 '06
60 2298
One thing that should be noted in this thread is that different
people will have different priorities. For example, some solutions
work better with small fonts, but I can't use small fonts. (Among other
vision problems I have monocular diplopia, believe it or not.)
This is one reason I prefer True Style, which conserves vertical space.
Different style decisions interact. I tend to use ridiculously short
variable names. If I used ridiculously long variable names, I'd surely
end up preferring shorter indentation than I use now.
(Also, since I became an algorithm designer, rather than software
provider,
*my* code isn't usually a deliverable, except in finished form.
Hence catering to external style requirements is no longer a
requirement
for me.)
Richard Heathfield wrote: James Dow Allen said:
I *do* like being able to line up begins and ends easily, so if I was ever forced to work on code that used (gasp!) 2-space indentation I'd become an indent(1) fan *real* quick. (2-space indentation may look OK on little fragments, but am I the only one that ever puts more than 3 or 4 lines of code into the body of a for or if?) ... Tabs being frowned upon, I got into the 2-space indent habit for Usenet posts
I post code too, sometimes, but if more than a tiny fragment it's
usually from real code. I replace the tabs, easily, at the same time
I add the control-M's.
I have no problem matching braces (because I lay them out Allman-style, so it's very obvious) - and anyway, vim can jump between { and } with a single keystroke, so even if it weren't obvious it wouldn't matter that much.
Even old-fashioned vi does that, but I only do when the matching brace
is off-screen or I'm troubleshooting a missing-brace error. I like to
just
stare at code and quickly grasp it.
Andrew Poelstra wrote: Am I the only one who ever nests blocks more than two levels deep? ... Running anything inside of the third loop would take 8 spaces with 2-space indentation, while it would take 32 spaces with your tabbing
You haven't looked at my code samples if you think I don't nest deeply.
:-)
I have various workarounds. As one example consider the idiom
for (Foo1; Foo2; Foo2)
if (Foo3)
enchant();
which seems to come up a lot, with *nothing* done in the loop unless
Foo3.
I often omit the indentation in this case, just as in the 2-D for shown
earlier.
I also often break up complex expressions into multiple lines, which
aids
readability even when the line wouldn't have become over-long.
strategy (not to mention the fact that will these new GUI's people are using, tab may or may not switch you from your editor window).
GUI's?? Naaah.
James Dow Allen
On Fri, 19 May 2006 11:43:09 GMT,
pete <pf*****@mindspring.com> wrote
in Msg. <44***********@mindspring.com> I prefer to start the broken lines with a binary operator, if possible,
Oh yes. Absolutely. I didn't check that with the re-posted code snippet.
robert
On Sat, 20 May 2006 19:00:31 +0100,
Chris Hills <ch***@phaedsys.org> wrote
in Msg. <YQ**************@phaedsys.demon.co.uk> In article <11**********************@j33g2000cwa.googlegroups .com>, Bill Pursell <bi**********@gmail.com> writes
Is using tabs for indentation a decision I'll regret? Ask me in 12 months. :)
You will.
Why not set the editor to replace tabs with spaces?
I did that for a while but didn't like haveing to step the cursor
through the individual spaces when navigating the code with arrow keys.
Of course this is an editor issue.
robert
On Sun, 21 May 2006 21:03:46 UTC, Ian Collins <ia******@hotmail.com>
wrote: Herbert Rosenau wrote: On Sat, 20 May 2006 12:25:25 UTC, "Bill Pursell" <bi**********@gmail.com> wrote:
James Dow Allen wrote:
Robert Latest wrote:
>On 18 May 2006 09:44:43 -0700, > Bill Pursell <bi**********@gmail.com> wrote > >>I've never found an indentation scheme for line continuations that I like....
>I always do it like this: > >if (really_long_name -> a && > (b == 8) && (c & 0x08) || > (another_boolean_condition) && > (yet_another() == 2) ) { > do _stuff() >}
I also do it that way: double-tab for the continuation. Given my track record for other's liking my style, I hope Robert doesn't decide to switch to something else now. :-)
>My "normal indent" is 4 spaces, ...
My "normal indent" is one TAB character, and I'm amazed people mess around with spaces. It seems futile to try a TAB other than 8 spaces, ...
<snip>
That's actually the motivation behind my looking for a new continuation style. I've also used double indent for continuations, but I've recently changed from being a tabstop=4 person to being a tabstop=8, and 16 spaces is too much for the line continuation. I don't want to go to half-indents, because I'm trying to go back to the tab-only indent style (I'm tired of using spaces just to conform to the wishes of people who don't know how to use an editor.)
It'd be cool if you could do:
if (this_is_the_first_line == 5 && \ \ this_is_the_continuation == 4)
and use the '\' to mark continuations both at the end of the line and at the begninning.
Impossible mission. But I do this instead:
if (this_is_the_first_line == 5 && this_is_the_continuation == 4 || (another_line != last_line && this == that) || !that) {
Double indention and logical operator in front of new line when the space of a single line is not enough to fit the complete condition. Same question I asked before, can this style be automated? It looks to me like quite a lot of the ideas presented in this thread are write once solutions.
Currently not - but it would possible to extend the editor to get it.
On other hand such complex if's are rare in practice.
--
Tschau/Bye
Herbert
Visit http://www.ecomstation.de the home of german eComStation
eComStation 1.2 Deutsch ist da!
Richard Heathfield wrote: James Dow Allen said:
I *do* like being able to line up begins and ends easily, so if I was ever forced to work on code that used (gasp!) 2-space indentation I'd become an indent(1) fan *real* quick. (2-space indentation may look OK on little fragments, but am I the only one that ever puts more than 3 or 4 lines of code into the body of a for or if?)
I use two-space indent, and I have found that it works very well. History: I used to use tabs (with 8-stops), but that got silly fast, and I converted to 4-stops (but still tabs). But then I got into Usenet. Tabs being frowned upon, I got into the 2-space indent habit for Usenet posts (because it was so much quicker!), and found that I liked it so much I adopted it for non-Usenet code too.
I have no problem matching braces (because I lay them out Allman-style, so it's very obvious) - and anyway, vim can jump between { and } with a single keystroke, so even if it weren't obvious it wouldn't matter that much.
And that explains so much.... en******@yahoo.com said: I have no problem matching braces (because I lay them out Allman-style, so it's very obvious) - and anyway, vim can jump between { and } with a single keystroke, so even if it weren't obvious it wouldn't matter that much.
And that explains so much....
Would you be so kind as to explain what you think it explains?
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999 http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
"Richard Heathfield" <in*****@invalid.invalid> wrote in message
news:V6********************@bt.com... en******@yahoo.com said:
I have no problem matching braces (because I lay them out Allman-style, so it's very obvious) - and anyway, vim can jump between { and } with a single keystroke, so even if it weren't obvious it wouldn't matter that much.
And that explains so much....
Would you be so kind as to explain what you think it explains?
Okay, now you snipped almost all the relevant context... Unbelievable!
I'm not even going to respond to your question...
Rod Pemberton
Rod Pemberton said: "Richard Heathfield" <in*****@invalid.invalid> wrote in message news:V6********************@bt.com... en******@yahoo.com said:
>> I have no problem matching braces (because I lay them out >> Allman-style, so it's very obvious) - and anyway, vim can jump between >> { and } with a single keystroke, so even if it weren't obvious it >> wouldn't matter that much. > > And that explains so much....
Would you be so kind as to explain what you think it explains?
Okay, now you snipped almost all the relevant context... Unbelievable! I'm not even going to respond to your question...
Then why reply?
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999 http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Richard Heathfield wrote: en******@yahoo.com said:
I have no problem matching braces (because I lay them out Allman-style, so it's very obvious) - and anyway, vim can jump between { and } with a single keystroke, so even if it weren't obvious it wouldn't matter that much.
And that explains so much....
Would you be so kind as to explain what you think it explains?
It (including the context you snipped) explains that you missed
the point in reading the earlier posting. en******@yahoo.com said: Richard Heathfield wrote: en******@yahoo.com said:
>> I have no problem matching braces (because I lay them out >> Allman-style, so it's very obvious) - and anyway, vim can jump between >> { and } with a single keystroke, so even if it weren't obvious it >> wouldn't matter that much. > > And that explains so much....
Would you be so kind as to explain what you think it explains?
It (including the context you snipped) explains that you missed the point in reading the earlier posting.
It does? Well, if you say so...
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999 http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
2006-05-20 <rK******************************@bt.com>, Richard Heathfield wrote: James Dow Allen said:
I *do* like being able to line up begins and ends easily, so if I was ever forced to work on code that used (gasp!) 2-space indentation I'd become an indent(1) fan *real* quick. (2-space indentation may look OK on little fragments, but am I the only one that ever puts more than 3 or 4 lines of code into the body of a for or if?)
I use two-space indent, and I have found that it works very well. History: I used to use tabs (with 8-stops), but that got silly fast, and I converted to 4-stops (but still tabs). But then I got into Usenet. Tabs being frowned upon, I got into the 2-space indent habit for Usenet posts (because it was so much quicker!), and found that I liked it so much I adopted it for non-Usenet code too.
I have no problem matching braces (because I lay them out Allman-style, so it's very obvious) - and anyway, vim can jump between { and } with a single keystroke, so even if it weren't obvious it wouldn't matter that much.
But yes, you're right - indent(1) is our friend.
gg=G preserves existing line numbers. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Andrew Koenig |
last post by:
Suppose I want to define a class hierarchy that represents expressions, for
use in a compiler or something similar.
We might imagine various kinds of expressions, classified by their top-level...
|
by: Stevey |
last post by:
I have the following XML file...
<?xml version="1.0"?>
<animals>
<animal>
<name>Tiger</name>
<questions>
<question index="0">true</question>
<question index="1">true</question>
</questions>
|
by: Chris Smith |
last post by:
'Morning,
Within the next few months, I'm going to embark upon a comparatively
rather large base of JavaScript code to be called from a web browser
environment. Not too awfully huge, but...
|
by: nospam |
last post by:
Ok, 3rd or is it the 4th time I have asked this question on Partial Types,
so, since it seems to me that Partial Types is still in the design or
development stages at Microsoft, I am going to ask...
|
by: Russell Silva |
last post by:
I have a class A with a member variable type vector<foo> which is
initialized upon construction (no standard () constructor):
class A {
protected:
vector<foo> foo_vector;
public:
A(const...
|
by: Ekqvist Marko |
last post by:
Hi,
I have one Access database table including questions and answers. Now
I need to give answer id automatically to questionID column. But I
don't know how it is best (fastest) to do?
table...
|
by: glenn |
last post by:
I am use to programming in php and the way session and post vars are past
from fields on one page through to the post page automatically where I can
get to their values easily to write to a...
|
by: phdscholar80 |
last post by:
I have the habit of using the scope resolution operator whenever I use
global functions. My premise is that it improves readability by
helping someone who is looking at the code for the first time...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |