E
Ersek, Laszlo
You keep making puns like that and you're going to be in a heap of
trouble.
Care to explain what "use a stake" means here? I tried to look it up,
with not much success.
Thanks,
lacos
You keep making puns like that and you're going to be in a heap of
trouble.
Care to explain what "use a stake" means here? I tried to look it up,
with not much success.
In a language (or programming style) without break and goto one can
make strong arguments about the behaviour of loops. After
while (E) { S; }
one can assert that !E is true (there may not be an "after" of
course).
Banning continue and non-terminal return statements also
simplifies the reasoning about the interaction of S and E.
It's a pun. Eric is playing on the oft quoted phrase "C does not use
a stack". Hence Lawrence's "heap" pun in reply.
Eric's did register on my humour meter but Lawrence is talking a load
of mallocs.
James Harris said:(As you know) that's not much of a deduction. So what advantage can
similar reasoning be expected to give in imperative programming?
(Not
functional programming which is another matter.) I've seen people
write about advantages of certain control structures but I've never
come across an explanation of the principles, if there are any.
For example the most general imperative loop construct would be of the
form
for (;{
<code>
if (c1) break;
<more code>
if (c2) break;
<even more code>
if (c3) break;
<etc>
}
Top and bottom decision loops as well as arbitrary mid decisions can
all be expressed using such a control structure. Is there something
about that form which inhibits reasoning?
I'm glad to hear it but in what way or ways does *continue* work
against reasoning?
I guess you are referring to mid-routine return statements. They can
return no value or a value of the wrong type.
Any other problems with
them from the point of view of reasoning?
Ben Bacarisse said:That one is not too bad because it is structured.
... if you make the assumption that <code> has one entry and
one exit, but it was not excluded that <code> might contain
even more break statements.
Ben Bacarisse said:Eric's did register on my humour meter but Lawrence is talking a load
of mallocs.
(e-mail address removed) (Richard Harter) writes:I am not good with smileys. I have tried, recently, to inject a few
in to my posts but I am not entirely happy with the results :-(As a result, I probably come over as serious and ponderous about
things that I take with a pinch of salt. Sorry if that is the case.To keep things light and topical, here is another single loop version
to ponder the merits of:for (i = 0; i < H*H && x[i/H][i%H] != 1; i++);I rather like it![]()
And well you should.
You could make it more efficient (if I have the syntax right)
with
int **y; /* use appropriate type */
for (i = 0, y = (int **)x; i <HH && y != 1; i++);
j = i%H; i /= H;
There is no end of good solutions.
Richard Harter, [email protected]://home.tiac.net/~cri,http://www.varinoma.com
It's not much to ask of the universe that it be fair;
it's not much to ask but it just doesn't happen.
Hey, let's not cast aspersions.
Eric said:... nor make it an automatic response to dish out this
type of static.
... if you make the assumption that <code> has one entry and
one exit, but it was not excluded that <code> might contain
even more break statements.
Once the style guidelines allows use of break statements,
one must inspect the - possibly long - section <code> for
more break statements.
Oi! Can't you take an 'int?
"Any references to Goto (an obscure Japanese admiral) are obscene,
unfit for your eyes and anyway don't mean what you think they do -
delete them" (notes on the Algol manual from a university course in
the 1970s).
David Bolt said:I think a pointer might help us understand the long and short of it.
IMO, this entire argument is null and void.
Eric Sosman said:... serving only to block progress, to limit the scope
of endeavor, to foul the nest. Participants are dys-functional
and deserve to be switched.
Ben Bacarisse said:Ben Bacarisse <[email protected]> writes:int *y;
for (i = 0, y = x[0]; i < H*H && y != 1; i++);
j = i%H; i /= H;
but that brings up another c.l.c FAP[1]: is indexing y from y[H]
onwards really permitted?
[1] Frequently Argued Point.
Isn't it generally agreed that the Standard expects 'y = x[0]' not to
(have to) work, but 'y = (int*)x' or 'y = (int*)&x' to work? Is
there any real contention on what the Standard expects on this
particular point (even though there is debate about how well it
says it)?
I am surprised you think anything like this could be "generally
agreed"![]()
Well, I did say "generally agreed", not "universally agreed."
To be more specific, isn't it essentially universally agreed that
using '(T*)&x' will get an array for the entire region
occupied by x, even if x is a multi-dimensional array? That
assertion seems pretty uncontroversial.
I toyed with using a pointer that unambiguously referred to the whole
array (I'd have gone for (void *)x) but I did not want to invite the
debate by including a cast that some might think is not needed. I
failed of course, since here we are again.
What, you're trying to say that there is debate about whether
or not a debate exists? In comp.lang.c? Preposterous!
Luca Forlizzi said:Ben Bacarisse said:Tim Rentsch <[email protected]> writes:<snip>
int *y;
for (i = 0, y = x[0]; i < H*H && y != 1; i++);
j = i%H; i /= H;
but that brings up another c.l.c FAP[1]: is indexing y from y[H]
onwards really permitted?[1] Frequently Argued Point.Isn't it generally agreed that the Standard expects 'y = x[0]' not to
(have to) work, but 'y = (int*)x' or 'y = (int*)&x' to work? Is
there any real contention on what the Standard expects on this
particular point (even though there is debate about how well it
says it)?I am surprised you think anything like this could be "generally
agreed"![]()
Well, I did say "generally agreed", not "universally agreed."
To be more specific, isn't it essentially universally agreed that
using '(T*)&x' will get an array for the entire region
occupied by x, even if x is a multi-dimensional array? That
assertion seems pretty uncontroversial.
I toyed with using a pointer that unambiguously referred to the whole
array (I'd have gone for (void *)x) but I did not want to invite the
debate by including a cast that some might think is not needed. I
failed of course, since here we are again.
What, you're trying to say that there is debate about whether
or not a debate exists? In comp.lang.c? Preposterous!
While I knew that the "Standard expects 'y = x[0]' not to (have to)
work", I didn't know
that "it essentially universally agreed that using '(T*)&x' will get
an array for the entire region occupied by x, even if x is a multi-
dimensional array". I don't have anything against it and it is not my
intention to reopen a debate on a F.A.P. but, just to improve my
knowledge on the Standard, I would like to know from what part(s) of
it that fact can be deduced. I confess that I don't understand much of
what the standard says about pointer conversions.
Could you please explain or give links to previous discussions about
this?
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.