Sujet : Re: question about linker
De : Keith.S.Thompson+u (at) *nospam* gmail.com (Keith Thompson)
Groupes : comp.lang.cDate : 12. Dec 2024, 02:27:53
Autres entêtes
Organisation : None to speak of
Message-ID : <87frmtwuzq.fsf@nosuchdomain.example.com>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
User-Agent : Gnus/5.13 (Gnus v5.13)
bart <
bc@freeuk.com> writes:
[...]
My experience of multi-level break is that there are two main use-cases:
>
* Used in the current loop only (not necessarily the innermost to an
observer). This is the most common
>
* Used to exit the outermost loop
>
So to support these, named or even numbered loops are not
necessary. (Eg. I use 'exit' or 'exit all'.)
I would oppose a change to C that only applied to innermost and
outermost loops. For one thing, I'm not aware of any other language
that does this (except perhaps your unnamed one). For another,
it's easy enough to define a feature that handles any arbitrary
nesting levels, by applying names (labels) to loops.
Having named labels do have some advantages, such as being absolute
while indices are relative. But sometimes you need an absolute
reference when refactoring and sometimes you want it relative.
I'm not sure what you mean by "relative". Do you have an example?
If, say, I have a "break 2" statement (the Bourne shell uses that
syntax), and I wanted to refactor the code, I'll at least have
to pay very close attention to the number, and likely change it.
Is that what you mean by "relative"? If I have "break NAME", it's
more likely that I won't have to change it. (Disclaimer: I don't
think I've ever used the "break N" feature of the Bourne shell.)
If duplicating within the same function, then you also need to think
about scope rules for those named labels.
That's hardly the only case where duplicating code within a function
can cause conflicts.
A common proposal is to use existing labels, whose scope is already
well defined. Labels have *function scope*. You just have to make
sure that all labels within a function are unique.
-- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.comvoid Void(void) { Void(); } /* The recursive call of the void */