Path: csiph.com!weretis.net!feeder9.news.weretis.net!news.quux.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Tim Rentsch Newsgroups: comp.lang.c Subject: Re: question about linker Date: Sat, 30 Nov 2024 09:54:30 -0800 Organization: A noiseless patient Spider Lines: 50 Message-ID: <86ser8obe1.fsf@linuxsc.com> References: <87plmfu2ub.fsf@nosuchdomain.example.com> <87frnbt9jn.fsf@nosuchdomain.example.com> <877c8nt255.fsf@nosuchdomain.example.com> <20241129142810.00007920@yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Date: Sat, 30 Nov 2024 18:54:39 +0100 (CET) Injection-Info: dont-email.me; posting-host="cbb822f8f85af8befb29db6227d47c5b"; logging-data="1973616"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19OMDXJLg/DfS2wkqCrM6wVVVLE7rHvm5w=" User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux) Cancel-Lock: sha1:7Eongzus7OaaJrncUo6E8SCHKjk= sha1:jpbkKFj3CipsOrdMwSCm3jeeI1w= Xref: csiph.com comp.lang.c:389238 Michael S 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.)