R
Richard Heathfield
CBFalconer said:
If you had taken it more seriously, ggets would be a better function.
Well, I didn't say it was dangerous. Nor do I agree that my claim is
ridiculous. This is what people want to be able to do:
1) initialise
2) main loop
2a) gather input
2b) process input
3) possibly do post-processing on intermediate results
4) produce output
5) clean up
6) quit
Okay, that doesn't quite cover all eventualities, but it gives a general
model for batch code. (The problem still remains for interactive code,
but let's keep our example simple.) The problem with ggets is that it
mandates an additional step within the main loop - effectively moving
part of the cleanup into the loop itself. Requiring people to do that
is a weakness. When they forget - and they will - the result can hardly
be called a leak, because it's more like a firehose.
You think wrong.
And scratch ggets too, until it does what it ought.
Richard said:CBFalconer said:Well, I certainly never saw [Pat Foley's ggets objection],
Oh, I see. There must be two CBFalconers then, since CBFalconer
did in fact post a prompt reply to Pat Foley.
Well, maybe I should modify my answer to 'I don't remember'. This
also indicates how seriously I took any such objection at the time.
If you had taken it more seriously, ggets would be a better function.
That's ridiculous. Similarly, you can say anything that uses
malloc to collect and store information is dangerous.
Well, I didn't say it was dangerous. Nor do I agree that my claim is
ridiculous. This is what people want to be able to do:
1) initialise
2) main loop
2a) gather input
2b) process input
3) possibly do post-processing on intermediate results
4) produce output
5) clean up
6) quit
Okay, that doesn't quite cover all eventualities, but it gives a general
model for batch code. (The problem still remains for interactive code,
but let's keep our example simple.) The problem with ggets is that it
mandates an additional step within the main loop - effectively moving
part of the cleanup into the loop itself. Requiring people to do that
is a weakness. When they forget - and they will - the result can hardly
be called a leak, because it's more like a firehose.
After all, it is just one more choice. You can use gets, ggets
fgets, getline (I think that is your routines name),
You think wrong.
getc, fscanf,
etc. as you wish. Scratch gets from that list.
And scratch ggets too, until it does what it ought.