Sujet : Re: question about linker
De : tr.17687 (at) *nospam* z991.linuxsc.com (Tim Rentsch)
Groupes : comp.lang.cDate : 30. Nov 2024, 18:54:30
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <86ser8obe1.fsf@linuxsc.com>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13
User-Agent : Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Michael S <
already5chosen@yahoo.com> writes:
IMHO, any way to mix more than one 'modifier' (not in C standard
meaning of the word, but in more general meaning) is potentially
confusing. It does not matter whether modifier is 'const' or '*'
or [] or ().
It surprises me that you would say this. Certainly there are type
forms that might be difficult to absorb (e.g., 'float *********')
but that doesn't mean they are necessarily confusing. There are two
obvious ways to write type forms that are easy to decode. One way
is to write any derivings right-to-left:
[] * (double,double) * float
which can be read directly as "array of pointer to function that
returns a pointer to float", and the other way is simply the reversal
of that:
float * (double,double) * []
which can be read right-to-left the same way. The constructors for
derived types (pointer, array, function) act like nouns. Qualifiers
such as const or volatile act like adjectives and always go to the
left of the noun they modify, so for example
[] volatile* float
is an array of volatile pointer to float, or in the other ordering
float volatile* []
which is simply a reversal of noun phrases, with any modifying
adjectives staying on the left side of the noun they modify.
The syntax used in C is harder to read for two reasons: one, the
ordering of derivations is both left-to-right and right-to-left,
depending on what derivation is being applied; and two, any
identifier being declared goes in the middle of the type rather
than at one of the ends. Both of those confusions can be removed
simply by using a consistent ordering, either left-to-right or
right-to-left (with qualifying adjectives always on the left of
the noun they modify).
Note that both of the consistent orderings correspond directly to a
natural English wording, which accounts for them being easier to
comprehend than C-style type forms. (I conjecture that some foreign
languages might not have that property, but since I am for the most
part ignorant of essentially all natural languages other than
English I have no more to say about that.)