gets() - dangerous?

R

Randy Howard

CBFalconer wrote
(in article said:
Whee - style war. Is this a private fight or can anybody join in?

Actually, I explicitly said upthread that it doesn't matter with
tools for reformatting being readily available, but if you feel
the need to argue about it anyway, be my guest. Who will you be
arguing with?
 
R

Randy Howard

Netocrat wrote
(in article said:
I thought it used K&R brace style and I took pete's recommendation as
seriously intended.

if (foo)
{
printf("foo detected\n");
}

Kind of strange to my eye.
 
R

Randy Howard

Flash Gordon wrote
(in article said:
You mean a set of sensible questions for tutors to set? ;-)

Two variants possible (at least).

1) Questions that professors SHOULD NOT ask because asking them
proves that they don't understand their subject well enough. If
we can do anything to educate the educators, life will get
better down the road for people using software written by their
students. Yes, pie in the sky, but why not try?

2) A listing of questions that will not be answered in c.l.c,
because you are supposed to learn how on your own. then, you
can reply to the standard questions (reverse a string,
palindrome, etc, etc) by a simple link to the wiki. They might
actually learn something useful while visiting, even if they
don't find a compilable solution to their problem.
 
R

Randy Howard

Netocrat wrote
(in article said:
If we find consensus on a common style for C code on the wiki, will you
take that comment back? ;-)

A) I don't really care what formatting convention is used on the
wiki. I think my disagreement on what Indian Hill means as a
format is the source of others deciding I want to argue about
it. I do not, for the record.

B) No. Solving style issues on a web site, and making Kenny's
opinions relevant are two radically different problems. One is
analogous to O(n log n) and the other is NP complete.
 
N

Netocrat

Among other things... However, I have given "non-real-life" C homework
to students to in order to drive home a certain aspect of a lesson. Only
when we discussed possible solutions the real life aspects came in.

A repository of insight-based problems would be useful.
Primarily: How to ask about homework questions. There was a discussion
within the last months where Chris Hills brought up a "template":
Start at <[email protected]>

I remember reading that and have added it as a reference post (link to
Google archive) to the introductory comp.lang.c page on the wiki.
Yourself, Chris Hills, Randy Howard or anyone else could import it into
the wiki under a new "Homework Problems" category if you'd like to expand
on it.
 
D

Default User

Randy said:
Netocrat wrote


if (foo)
{
printf("foo detected\n");
}

Kind of strange to my eye.

This is my favored style. The braces, like the statements, are part of
the same code entity, the block. It makes sense for them to be aligned.
They aren't part of the if().

Not all that many people agree.


Brian
 
N

Netocrat

Flash Gordon wrote


Two variants possible (at least).

1) Questions that professors SHOULD NOT ask because asking them proves
that they don't understand their subject well enough. If we can do
anything to educate the educators, life will get better down the road
for people using software written by their students. Yes, pie in the
sky, but why not try?

So they could be used by students to verify whether their instructors are
up to scratch as well as by instructors to skill up.
2) A listing of questions that will not be answered in c.l.c, because
you are supposed to learn how on your own. then, you can reply to the
standard questions (reverse a string, palindrome, etc, etc) by a simple
link to the wiki. They might actually learn something useful while
visiting, even if they don't find a compilable solution to their
problem.

A "common homework problem - do not solve" list seems like a good idea -
source code for those problems would never be published on the wiki, but
hints and suggestions could be.
 
N

Netocrat

]
A) I don't really care what formatting convention is used on the wiki. I
think my disagreement on what Indian Hill means as a format is the
source of others deciding I want to argue about it. I do not, for the
record.

We don't have to argue, but if you, pete and I are using different
understandings of what that style means, we're not communicating
effectively.

I've never coded to Indian Hill style guidelines before so I'm basing my
understanding on this:
<http://www.chris-lott.org/resources/cstyle/indhill-cstyle.html>.

[...]
 
C

CBFalconer

Randy said:
Netocrat wrote


if (foo)
{
printf("foo detected\n");
}

Kind of strange to my eye.

Mine too. However it actually makes a sort of sense. The if
statement controls stuff, and all that stuff is indented. I use
exactly this sort of thing in Pascal, where things may read:

IF whatever THEN BEGIN
stuff;
and more stuff; END;
still more stuff.

Somebody in this thread has been stripping attributions of quoted
material. You know who you are. Please don't.

--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell.org/google/>
 
N

Netocrat

I don't see anything intrinsically wrong with it, but I'm not accustomed
to it either. According to the Jargon file, that's Whitesmiths style:
This is my favored style. The braces, like the statements, are part of
the same code entity, the block. It makes sense for them to be aligned.
They aren't part of the if().

Not all that many people agree.

I don't think the justification you give has any more or less objective
weight than saying for another alignment that "the braces delimit the
block, and should be distinct from it". Bracing style is probably a
personal choice in the absence of other requirements.
 
R

Randy Howard

Netocrat wrote
(in article said:
I don't see anything intrinsically wrong with it, but I'm not accustomed
to it either. According to the Jargon file, that's Whitesmiths style:

Ack, you're right. I was mixing up the two in my mind. Sorry
about confusing the issue. :-(
 
R

Randy Howard

CBFalconer wrote
(in article said:
Randy Howard wrote:

Mine too. However it actually makes a sort of sense. The if
statement controls stuff, and all that stuff is indented. I use
exactly this sort of thing in Pascal, where things may read:

IF whatever THEN BEGIN
stuff;
and more stuff; END;
still more stuff.

It's admittedly been a while since I did Pascal ('88 or so?),
but wouldn't the actual analogy be:

IF whatever THEN
BEGIN
stuff;
and more stuff;
END;
still more stuff.

???
 
M

Malcolm

Netocrat said:
A "common homework problem - do not solve" list seems like a good idea -
source code for those problems would never be published on the wiki, but
hints and suggestions could be.
Good idea.

One problem is that we should discourage newbies from diving into a question
and simply writing code. Normally it is best to plan first, and get advice
before you start coding, rather than make a hash of things and then get a
helper to patch things up.
Unfortunately that makes it too easy for someone who has no intention of
putting any effort in to ask for help, in the hope of getting a working
program back. So most regs ask for an attempted program.

A wiki with homework hints would sove this.
 
P

pete

The brace style is a little different and I was serious.
I don't see anything intrinsically wrong with it,
but I'm not accustomed
to it either. According to the Jargon file, that's Whitesmiths style:


I don't think the justification you give
has any more or less objective
weight than saying for another alignment that "the braces delimit the
block, and should be distinct from it". Bracing style is probably a
personal choice in the absence of other requirements.

/* This is Indian Hill */

if (expr) {
statement;
} else {
statement;
statement;
}

http://www.psgd.org/paul/docs/cstyle/cstyle09.htm
http://www.psgd.org/paul/docs/cstyle/cstyle.htm
http://www.google.com/search?hl=en&ie=ISO-8859-1&q="indian+hill"+C+style
 
P

pete

Default said:
This is my favored style. The braces, like the statements, are part of
the same code entity, the block.
It makes sense for them to be aligned.
They aren't part of the if().

Not all that many people agree.

Ordinary Indian Hill is like this:
if (expr) {
statement;
}

It's when you have a textually too long expression
that Indian Hill style is like:
if (expression ...................
&& ......................)
{
statement;
}
 
C

CBFalconer

Randy said:
CBFalconer wrote

It's admittedly been a while since I did Pascal ('88 or so?),
but wouldn't the actual analogy be:

IF whatever THEN
BEGIN
stuff;
and more stuff;
END;
still more stuff.

Yup. But in both languages my objective is clarity consumate with
conservation of vertical space. Thus I also use:

if (whatever) {
stuff;
and more stuff;
}
still more stuff.

--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell.org/google/>
 
J

Joe Wright

Randy said:
Netocrat wrote



if (foo)
{
printf("foo detected\n");
}

Kind of strange to my eye.
Strange indeed. I would write it..

if (foo) {
printf("foo detected\n");
}
 
D

Default User

Netocrat said:
I don't think the justification you give has any more or less
objective weight than saying for another alignment that "the braces
delimit the block, and should be distinct from it". Bracing style is
probably a personal choice in the absence of other requirements.

Certainly, that's why there are personal preferences. I had
independently developed Whitesmith's on my own. In some of my early
projects, I'd use a ruler to check for misaligned stuff on printouts,
so I found it easier to have the braces part of the block I was
checking.



Brian
 
D

Default User

pete said:
Ordinary Indian Hill is like this:
if (expr) {
statement;
}

Yeah, I didn't notice what he called it. The style I use is called
Whitesmith's. I think that was the place Plaugher used to work.



Brian
 
D

Default User

CBFalconer said:
Mine too. However it actually makes a sort of sense. The if
statement controls stuff, and all that stuff is indented.


The theory behind Whitesmith's is that stuff between braces is a
compound statement. If you'd indent a single statement, why not a
compound.

However, trying to apply logic isn't going to convince many people. You
like what you like. The most important thing on any cooperative project
is to pick a style and make it consistent. If that happens to be OTBS,
that would be fine, even though not a style I've used in 20 years.

It's easier these days with indenters and text editors that you can set
for auto-indent in various styles.



Brian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top