Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Somebody's terminal is dropping bits. I found a pile of them over in the corner.


devel / comp.lang.c / Word For Today: “Uglification”

SubjectAuthor
* Word For Today: “Uglification”Lawrence D'Oliveiro
+* Re: Word For Today: “Uglification”Keith Thompson
|`* Re: Word For Today: “Uglification”Lawrence D'Oliveiro
| `- Re: Word For Today: “Uglification”Keith Thompson
+* Re: Word For Today: “Uglification”Kaz Kylheku
|`* Re: Word For Today: “Uglification”Tim Rentsch
| `* Re: Word For Today: “Uglification”Keith Thompson
|  +* Re: Word For Today: “Uglification”Scott Lurndal
|  |+- Re: Word For Today: “Uglification”Scott Lurndal
|  |`* Re: Word For Today: “Uglification”Keith Thompson
|  | +- Re: Word For Today: “Uglification”Scott Lurndal
|  | `- Re: Word For Today: “Uglification”David Brown
|  +* Re: Word For Today: “Uglification”Keith Thompson
|  |`* Re: Word For Today: “Uglification”Scott Lurndal
|  | `* Re: Word For Today: “Uglification”Keith Thompson
|  |  `* Re: Word For Today: “Uglification”Kaz Kylheku
|  |   `* Re: Word For Today: “Uglification”Keith Thompson
|  |    `- Re: Word For Today: “Uglification”David Brown
|  `- Re: Word For Today: “Uglification”Tim Rentsch
+* Re: Word For Today: “Uglification”James Kuyper
|`* Re: Word For Today: “Uglification”Lawrence D'Oliveiro
| +- Re: Word For Today: “Uglification”Lawrence D'Oliveiro
| +* Re: Word For Today: “Uglification”Kaz Kylheku
| |`* Re: Word For Today: “Uglification”Richard Kettlewell
| | +* Re: Word For Today: “Uglification”David Brown
| | |+* Re: Word For Today: “Uglification”Anton Shepelev
| | ||`* Re: Word For Today: “Uglification”bart
| | || +* Re: Word For Today: “Uglification”Anton Shepelev
| | || |`* Re: Word For Today: “Uglification”bart
| | || | `* Re: Word For Today: “Uglification”Kaz Kylheku
| | || |  `* Re: Word For Today: “Uglification”bart
| | || |   +* Re: Word For Today: “Uglification”Keith Thompson
| | || |   |+* Re: Word For Today: “Uglification”bart
| | || |   ||+* Re: Word For Today: “Uglification”Michael S
| | || |   |||+* Re: Word For Today: “Uglification”Keith Thompson
| | || |   ||||`* Re: Word For Today: “Uglification”David Brown
| | || |   |||| `* Re: Word For Today: “Uglification”Keith Thompson
| | || |   ||||  `- Re: Word For Today: “Uglification”David Brown
| | || |   |||+- Re: Word For Today: “Uglification”David Brown
| | || |   |||`- Re: Word For Today: “Uglification”Kaz Kylheku
| | || |   ||`* Re: Word For Today: “Uglification”Keith Thompson
| | || |   || `- Re: Word For Today: “Uglification”bart
| | || |   |`- Re: Word For Today: “Uglification”Nick Bowler
| | || |   `- Re: Word For Today: “Uglification”Kaz Kylheku
| | || `- Re: Word For Today: “Uglification”Kaz Kylheku
| | |`- Re: Word For Today: “Uglification”Blue-Maned_Hawk
| | `* Re: Word For Today: “Uglification”Lawrence D'Oliveiro
| |  +* Re: Word For Today: “Uglification”Keith Thompson
| |  |`* Re: Word For Today: “Uglification”Richard Kettlewell
| |  | `* Re: Word For Today: “Uglification”Keith Thompson
| |  |  `* Re: Word For Today: “Uglification”Lawrence D'Oliveiro
| |  |   +- Re: Word For Today: “Uglification”Kaz Kylheku
| |  |   +- Re: Word For Today: “Uglification”Keith Thompson
| |  |   `* Re: Word For Today: “Uglification”Scott Lurndal
| |  |    `* Re: Word For Today: “Uglification”Lawrence D'Oliveiro
| |  |     +* Re: Word For Today: “Uglification”Keith Thompson
| |  |     |+- Re: Word For Today: “Uglification”Richard Kettlewell
| |  |     |`- Re: Word For Today: “Uglification”Kaz Kylheku
| |  |     `- Re: Word For Today: “Uglification”Scott Lurndal
| |  `- Re: Word For Today: “Uglification”Kaz Kylheku
| `* Re: Word For Today: “Uglification”James Kuyper
|  `* Re: Word For Today: “Uglification”Lawrence D'Oliveiro
|   +- Re: Word For Today: “Uglification”Keith Thompson
|   `* Re: Word For Today: “Uglification”James Kuyper
|    `* Re: Word For Today: “Uglification”Lawrence D'Oliveiro
|     +- Re: Word For Today: “Uglification”Kaz Kylheku
|     `- Re: Word For Today: “Uglification”James Kuyper
`- Re: Word For Today: “Uglification”Kaz Kylheku

Pages:123
Word For Today: “Uglification”

<uso6or$3t3jn$3@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34292&group=comp.lang.c#34292

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo...@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.lang.c
Subject: Word For Today: “Uglification”
Date: Tue, 12 Mar 2024 00:14:19 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 26
Message-ID: <uso6or$3t3jn$3@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 12 Mar 2024 00:14:19 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="11b38f0fdef8c619d895dc1d0c253c52";
logging-data="4099703"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+NtNOaCp7zw/13vGFc/Nq7"
User-Agent: Pan/0.155 (Kherson; fc5a80b8)
Cancel-Lock: sha1:VIXZgNlUXfyFMltEVjSa6LIz7SQ=
 by: Lawrence D'Oliv - Tue, 12 Mar 2024 00:14 UTC

From /usr/include/«arch»/bits/select.h on my Debian system:

#define __FD_ZERO(s) \
do { \
unsigned int __i; \
fd_set *__arr = (s); \
for (__i = 0; __i < sizeof (fd_set) / sizeof (__fd_mask); ++__i) \
__FDS_BITS (__arr)[__i] = 0; \
} while (0)

Note how this macro brings the entire expression for “s” into the
scope containing those temporary “__i” and “__arr” variables. You just
better hope they won’t clash.

I think there is a clause in the C spec that says names beginning with
underscores (“uglified” names, I think they’re called) are reserved
for library implementors or something. But what happens if one library
implementation depends on another? What keeps the choices of names
from clashing in that situation? Just luck, I guess.

Basically, string-substitution macros are fiddly, fragile, and prone
to mysterious syntax errors in the target language if you’re not
careful. I thought initially that this was down to limitations in the
the C/C++ preprocessor; maybe a more powerful one, like m4, would
help. But it turns that is even more fiddly and fragile, and prone to
mysterious syntax errors if you’re not careful.

Re: Word For Today: “Uglification”

<87wmq88d45.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34294&group=comp.lang.c#34294

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: Word For Today: “Uglification”
Date: Mon, 11 Mar 2024 18:15:06 -0700
Organization: None to speak of
Lines: 43
Message-ID: <87wmq88d45.fsf@nosuchdomain.example.com>
References: <uso6or$3t3jn$3@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: dont-email.me; posting-host="de8f53c78bf32f77c14d770a36ea4d62";
logging-data="4123696"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18DEp0gEKTDgJfw0kc3Dhg5"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:xLWbMNrLJWSNpR+p/EmXr3UYUZ0=
sha1:S6MUPxOHdwCEHQ5rBG4ZByQfTQY=
 by: Keith Thompson - Tue, 12 Mar 2024 01:15 UTC

Lawrence D'Oliveiro <ldo@nz.invalid> writes:
> From /usr/include/«arch»/bits/select.h on my Debian system:
>
> #define __FD_ZERO(s) \
> do { \
> unsigned int __i; \
> fd_set *__arr = (s); \
> for (__i = 0; __i < sizeof (fd_set) / sizeof (__fd_mask); ++__i) \
> __FDS_BITS (__arr)[__i] = 0; \
> } while (0)
>
> Note how this macro brings the entire expression for “s” into the
> scope containing those temporary “__i” and “__arr” variables. You just
> better hope they won’t clash.
>
> I think there is a clause in the C spec that says names beginning with
> underscores (“uglified” names, I think they’re called) are reserved
> for library implementors or something. But what happens if one library
> implementation depends on another? What keeps the choices of names
> from clashing in that situation? Just luck, I guess.

N1570 7.1.3:

All identifiers that begin with an underscore and either an
uppercase letter or another underscore are always reserved for any
use.

All identifiers that begin with an underscore are always reserved
for use as identifiers with file scope in both the ordinary and tag
name spaces.

I've never heard them call "uglified", though I suppose it's somewhat apt.

If the standard library includes code from two or more different
implementers, all implementers have a very strong interest in avoiding
any clashes. I don't see a real problem here.

[...]

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Medtronic
void Void(void) { Void(); } /* The recursive call of the void */

Re: Word For Today: “Uglification”

<usober$3u4ig$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34296&group=comp.lang.c#34296

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo...@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.lang.c
Subject: Re: Word For Today: “Uglification”
Date: Tue, 12 Mar 2024 01:34:20 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 7
Message-ID: <usober$3u4ig$1@dont-email.me>
References: <uso6or$3t3jn$3@dont-email.me>
<87wmq88d45.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 12 Mar 2024 01:34:20 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="11b38f0fdef8c619d895dc1d0c253c52";
logging-data="4133456"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/17xYKYpqs4upQQsU7mkFl"
User-Agent: Pan/0.155 (Kherson; fc5a80b8)
Cancel-Lock: sha1:HFAHz5K3okgXjuAR8YGoVkcLpjA=
 by: Lawrence D'Oliv - Tue, 12 Mar 2024 01:34 UTC

On Mon, 11 Mar 2024 18:15:06 -0700, Keith Thompson wrote:

> If the standard library includes code from two or more different
> implementers, all implementers have a very strong interest in avoiding
> any clashes. I don't see a real problem here.

.... until the Birthday Paradox comes into play.

Re: Word For Today: “Uglification”

<87o7bk88ew.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34297&group=comp.lang.c#34297

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: Word For Today: “Uglification”
Date: Mon, 11 Mar 2024 19:56:39 -0700
Organization: None to speak of
Lines: 19
Message-ID: <87o7bk88ew.fsf@nosuchdomain.example.com>
References: <uso6or$3t3jn$3@dont-email.me>
<87wmq88d45.fsf@nosuchdomain.example.com>
<usober$3u4ig$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="de8f53c78bf32f77c14d770a36ea4d62";
logging-data="4161228"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/0VsDquywoLKrhLcfWS1t2"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:0Qw+UtYzJMm9RPuUBvNH6w0m22k=
sha1:bWimW+WQLzQyJwb+mt4faeJ177Q=
 by: Keith Thompson - Tue, 12 Mar 2024 02:56 UTC

Lawrence D'Oliveiro <ldo@nz.invalid> writes:
> On Mon, 11 Mar 2024 18:15:06 -0700, Keith Thompson wrote:
>
>> If the standard library includes code from two or more different
>> implementers, all implementers have a very strong interest in avoiding
>> any clashes. I don't see a real problem here.
>
> ... until the Birthday Paradox comes into play.

The Birthday Paradox comes into play for random birthdays over which the
participants have no control, not for library implementers who control
their own namespaces and are strongly motivated to avoid collisions.

Do you have a real-world example of such a collision?

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Medtronic
void Void(void) { Void(); } /* The recursive call of the void */

Re: Word For Today: “Uglification”

<20240311202758.193@kylheku.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34299&group=comp.lang.c#34299

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 433-929-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c
Subject: Re: Word For Today: “Uglification”
Date: Tue, 12 Mar 2024 03:30:55 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 22
Message-ID: <20240311202758.193@kylheku.com>
References: <uso6or$3t3jn$3@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 12 Mar 2024 03:30:55 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="103d6665e02695c45444ee5fbac9bd46";
logging-data="101344"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/gud0bg//B6KlWWlCXqUiBuPe4AOzR7N0="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:kBQkGucaMTKp6f2cckv1hA+qxx8=
 by: Kaz Kylheku - Tue, 12 Mar 2024 03:30 UTC

On 2024-03-12, Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
> From /usr/include/«arch»/bits/select.h on my Debian system:
>
> #define __FD_ZERO(s) \
> do { \
> unsigned int __i; \
> fd_set *__arr = (s); \

This assignment has value; it checks that, loosely speaking,
s is an "assignment compatible" pointer with a fd_set *,
so that there is a diagnostic if the macro is applied to
an object of the wrong type.

> for (__i = 0; __i < sizeof (fd_set) / sizeof (__fd_mask); ++__i) \
> __FDS_BITS (__arr)[__i] = 0; \

Here, I would have done memset(__arr, 0, sizeof *__arr).

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Re: Word For Today: “Uglification”

<usopec$4eob$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34300&group=comp.lang.c#34300

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: jameskuy...@alumni.caltech.edu (James Kuyper)
Newsgroups: comp.lang.c
Subject: Re: Word For Today: “Uglification”
Date: Tue, 12 Mar 2024 01:33:00 -0400
Organization: A noiseless patient Spider
Lines: 60
Message-ID: <usopec$4eob$1@dont-email.me>
References: <uso6or$3t3jn$3@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 12 Mar 2024 05:33:00 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="1b2f7d6314d5bff909509365f5964211";
logging-data="146187"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/oZHaDzPWfjliit8qKvBKONQO4vTBCwzM="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:tRoRJOePMqwn+M0Ekte7KchxsZM=
In-Reply-To: <uso6or$3t3jn$3@dont-email.me>
Content-Language: en-US
 by: James Kuyper - Tue, 12 Mar 2024 05:33 UTC

On 3/11/24 20:14, Lawrence D'Oliveiro wrote:
> From /usr/include/«arch»/bits/select.h on my Debian system:
>
> #define __FD_ZERO(s) \
> do { \
> unsigned int __i; \
> fd_set *__arr = (s); \
> for (__i = 0; __i < sizeof (fd_set) / sizeof (__fd_mask); ++__i) \
> __FDS_BITS (__arr)[__i] = 0; \
> } while (0)
>
> Note how this macro brings the entire expression for “s” into the
> scope containing those temporary “__i” and “__arr” variables. You just
> better hope they won’t clash.
>
> I think there is a clause in the C spec that says names beginning with
> underscores (“uglified” names, I think they’re called) are reserved
> for library implementors or something. But what happens if one library
> implementation depends on another? What keeps the choices of names
> from clashing in that situation? Just luck, I guess.

They are called "reserved identifiers", a name which more directly
addresses their purpose. They don't just start with underscores - there
are several different sets of identifiers, reserved for different
purposes. See section 7.1.3 for details. They are provided by *an*
implementation. Note the use of the singular. As far as the standard is
concerned, there is only one implementation that is responsible for
translating and executing a given program. What the implementation
implements is not just the C standard library, but also the C language.
Libraries other than the C standard library do have implementations, but
those implementations are not what the C standard is usually talking
about when it uses that word.

The standard defines an implementation as "particular set of software,
running in a particular translation environment under particular control
options, that performs translation of programs for, and supports
execution of functions in, a particular execution environment" (3.12).

Note that the software must be running before it can be called an
implementation. A program that is just sitting on your computer waiting
to be executed cannot qualify. Also, if the software has options,
choosing different options when you start it up can make it a different
implementation of C.

You can have an implementation of C where different parts are
implemented by different implementors - in fact, it's quite common for
the language, the C standard library, and the linker to be implemented
by different organizations. However, the combination of those parts only
qualifies as a conforming implementation of C if those different parts
work together as required by the standard. Avoiding the conflicts you're
talking about is a pre-requisite for doing so.

Most implementors that implement only part of a C implementation make
sure to test whether their part works together with popular
implementations of the other parts, and to document which ones they do
work with. If you cobble together a complete implementation from parts
implemented by different implementors, you'd better check their
documentation to see if at least one of them has tested compatibility
with all of the others. If none of them has done such testing, you
shouldn't count on them working together as a conforming C implementation.

Re: Word For Today: “Uglification”

<usort1$4t2r$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34301&group=comp.lang.c#34301

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo...@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.lang.c
Subject: Re: Word For Today: “Uglification”
Date: Tue, 12 Mar 2024 06:14:58 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 26
Message-ID: <usort1$4t2r$1@dont-email.me>
References: <uso6or$3t3jn$3@dont-email.me> <usopec$4eob$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 12 Mar 2024 06:14:58 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="11b38f0fdef8c619d895dc1d0c253c52";
logging-data="160859"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+7vodxXPA5z6aLfVPMPT5g"
User-Agent: Pan/0.155 (Kherson; fc5a80b8)
Cancel-Lock: sha1:LoH4OiIC7HOCZuezkv/YJydKH1k=
 by: Lawrence D'Oliv - Tue, 12 Mar 2024 06:14 UTC

On Tue, 12 Mar 2024 01:33:00 -0400, James Kuyper wrote:

> They are called "reserved identifiers", a name which more directly
> addresses their purpose. They don't just start with underscores - there
> are several different sets of identifiers, reserved for different
> purposes. See section 7.1.3 for details. They are provided by *an*
> implementation. Note the use of the singular.

Looking at the C99 spec, section 7.1.3:

Also reserved for the implementor are all external identifiers
beginning with an underscore, and all other identifiers beginning
with an underscore followed by a capital letter or an underscore.
This gives a name space for writing the numerous behind-the-scenes
non-external macros and functions a library needs to do its job
properly.

The problem I have with that is the singular form of “library”. In a
typical Linux distro, you could have thousands of libraries installed.
I just did this command on my Debian system:

dpkg-query -l lib*dev | wc -l

and the answer came back “1037”. The idea that a C-language
implementation and run-time environment is any sense monolithic seems
hopelessly out of touch.

Re: Word For Today: “Uglification”

<20240311231053.559@kylheku.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34302&group=comp.lang.c#34302

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 433-929-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c
Subject: Re: Word For Today: “Uglification”
Date: Tue, 12 Mar 2024 06:15:38 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 35
Message-ID: <20240311231053.559@kylheku.com>
References: <uso6or$3t3jn$3@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 12 Mar 2024 06:15:38 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="103d6665e02695c45444ee5fbac9bd46";
logging-data="162126"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+cj1RO169DjPhR2zIVXnjW3pAFp76B9WQ="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:wNQFD2/DmKq8F73/QLMZA3yemus=
 by: Kaz Kylheku - Tue, 12 Mar 2024 06:15 UTC

On 2024-03-12, Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
> From /usr/include/«arch»/bits/select.h on my Debian system:
>
> #define __FD_ZERO(s) \
> do { \
> unsigned int __i; \
> fd_set *__arr = (s); \
> for (__i = 0; __i < sizeof (fd_set) / sizeof (__fd_mask); ++__i) \
> __FDS_BITS (__arr)[__i] = 0; \
> } while (0)
>
> Note how this macro brings the entire expression for “s” into the
> scope containing those temporary “__i” and “__arr” variables. You just
> better hope they won’t clash.
>
> I think there is a clause in the C spec that says names beginning with
> underscores (“uglified” names, I think they’re called) are reserved
> for library implementors or something. But what happens if one library
> implementation depends on another? What keeps the choices of names
> from clashing in that situation? Just luck, I guess.

That doesn't happen. There is only one library that's part of the
language implementation, and those identifiers are reserved for that.

Any third party library that is not part of the implementation cannot
use these identifiers with the absolute certainty that they don't clash
with anything.

Standard C doesn't offer a solution for the problem of party library
writers needing private identifiers in their headers.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Re: Word For Today: “Uglification”

<usos8q$51a7$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34303&group=comp.lang.c#34303

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo...@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.lang.c
Subject: Re: Word For Today: “Uglification”
Date: Tue, 12 Mar 2024 06:21:14 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 12
Message-ID: <usos8q$51a7$1@dont-email.me>
References: <uso6or$3t3jn$3@dont-email.me> <usopec$4eob$1@dont-email.me>
<usort1$4t2r$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 12 Mar 2024 06:21:14 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="11b38f0fdef8c619d895dc1d0c253c52";
logging-data="165191"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19yVGNbDlTOSyVS/gQX4nN1"
User-Agent: Pan/0.155 (Kherson; fc5a80b8)
Cancel-Lock: sha1:/C1gz1OQrOgvxzZBlEsn+KPOoNI=
 by: Lawrence D'Oliv - Tue, 12 Mar 2024 06:21 UTC

On Tue, 12 Mar 2024 06:14:58 -0000 (UTC), I wrote:

> I just did this command on my Debian system:
>
> dpkg-query -l lib*dev | wc -l

Let me amend that: the more accurate command (counting only installed
libraries, not all the ones the package system knows about) would be

dpkg-query -l lib\*dev | grep ^i | wc -l

which produces a result of 320 on my system.

Re: Word For Today: “Uglification”

<20240312003531.349@kylheku.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34304&group=comp.lang.c#34304

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 433-929-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c
Subject: Re: Word For Today: “Uglification”
Date: Tue, 12 Mar 2024 07:44:19 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 26
Message-ID: <20240312003531.349@kylheku.com>
References: <uso6or$3t3jn$3@dont-email.me> <usopec$4eob$1@dont-email.me>
<usort1$4t2r$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 12 Mar 2024 07:44:19 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="103d6665e02695c45444ee5fbac9bd46";
logging-data="192328"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+1mCNuO8/jiEBh82P3gUX7e87hjSfm13I="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:W8UhRC6kUXA5q0Ty3rbUjinxYcc=
 by: Kaz Kylheku - Tue, 12 Mar 2024 07:44 UTC

On 2024-03-12, Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
> The problem I have with that is the singular form of “library”. In a
> typical Linux distro, you could have thousands of libraries installed.
> I just did this command on my Debian system:
>
> dpkg-query -l lib*dev | wc -l
>
> and the answer came back “1037”. The idea that a C-language
> implementation and run-time environment is any sense monolithic seems
> hopelessly out of touch.

There is no such out-of-touch idea. In (say) a Glibc-based system, only
the GCC, Glibc and kernel headers are part of the implementation (which
comprises C, POSIX plus GNU and Linux extensions), and only the GCC and
Glibc library components and their external names.

Other libraries are third parties; the __ and _[A-Z] namespace
simply doesn't belong to them.

C doesn't provide any special tools for the application developer and
third party code to avoid clashes among themselves.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Re: Word For Today: “Uglification”

<wwvwmq7x4ex.fsf@LkoBDZeT.terraraq.uk>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34305&group=comp.lang.c#34305

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!paganini.bofh.team!2.eu.feeder.erje.net!feeder.erje.net!feeds.news.ox.ac.uk!news.ox.ac.uk!earthli!nntp.terraraq.uk!.POSTED.tunnel.sfere.anjou.terraraq.org.uk!not-for-mail
From: inva...@invalid.invalid (Richard Kettlewell)
Newsgroups: comp.lang.c
Subject: Re: Word For Today: “Uglification”
Date: Tue, 12 Mar 2024 08:03:50 +0000
Organization: terraraq NNTP server
Message-ID: <wwvwmq7x4ex.fsf@LkoBDZeT.terraraq.uk>
References: <uso6or$3t3jn$3@dont-email.me> <usopec$4eob$1@dont-email.me>
<usort1$4t2r$1@dont-email.me> <20240312003531.349@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: innmantic.terraraq.uk; posting-host="tunnel.sfere.anjou.terraraq.org.uk:172.17.207.6";
logging-data="32030"; mail-complaints-to="usenet@innmantic.terraraq.uk"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:sKkmYE4C71+Z71apDHVzm4+Hx3Q=
X-Face: h[Hh-7npe<<b4/eW[]sat,I3O`t8A`(ej.H!F4\8|;ih)`7{@:A~/j1}gTt4e7-n*F?.Rl^
F<\{jehn7.KrO{!7=:(@J~]<.[{>v9!1<qZY,{EJxg6?Er4Y7Ng2\Ft>Z&W?r\c.!4DXH5PWpga"ha
+r0NzP?vnz:e/knOY)PI-
X-Boydie: NO
 by: Richard Kettlewell - Tue, 12 Mar 2024 08:03 UTC

Kaz Kylheku <433-929-6894@kylheku.com> writes:
> On 2024-03-12, Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
>> and the answer came back “1037”. The idea that a C-language
>> implementation and run-time environment is any sense monolithic seems
>> hopelessly out of touch.
>
> There is no such out-of-touch idea. In (say) a Glibc-based system, only
> the GCC, Glibc and kernel headers are part of the implementation (which
> comprises C, POSIX plus GNU and Linux extensions), and only the GCC and
> Glibc library components and their external names.
>
> Other libraries are third parties; the __ and _[A-Z] namespace
> simply doesn't belong to them.
>
> C doesn't provide any special tools for the application developer and
> third party code to avoid clashes among themselves.

That’s true, but AFAICT it’s exactly what Lawrence is complaining about:
there’s nothing in the language spec to help those thousand other
libraries avoid name clashes.

--
https://www.greenend.org.uk/rjk/

Re: Word For Today: “Uglification”

<usp9m5$7it7$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34306&group=comp.lang.c#34306

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: Word For Today: “Uglification”
Date: Tue, 12 Mar 2024 11:10:13 +0100
Organization: A noiseless patient Spider
Lines: 38
Message-ID: <usp9m5$7it7$1@dont-email.me>
References: <uso6or$3t3jn$3@dont-email.me> <usopec$4eob$1@dont-email.me>
<usort1$4t2r$1@dont-email.me> <20240312003531.349@kylheku.com>
<wwvwmq7x4ex.fsf@LkoBDZeT.terraraq.uk>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 12 Mar 2024 10:10:13 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="28b784db58e8619079c79416bf7fd792";
logging-data="248743"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18ZVdrRRt6YsFpksRqZ+TnNcWQpweAV9dw="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.11.0
Cancel-Lock: sha1:fQ8/ZePCFLSJSR267g5ebadLK/4=
In-Reply-To: <wwvwmq7x4ex.fsf@LkoBDZeT.terraraq.uk>
Content-Language: en-GB
 by: David Brown - Tue, 12 Mar 2024 10:10 UTC

On 12/03/2024 09:03, Richard Kettlewell wrote:
> Kaz Kylheku <433-929-6894@kylheku.com> writes:
>> On 2024-03-12, Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
>>> and the answer came back “1037”. The idea that a C-language
>>> implementation and run-time environment is any sense monolithic seems
>>> hopelessly out of touch.
>>
>> There is no such out-of-touch idea. In (say) a Glibc-based system, only
>> the GCC, Glibc and kernel headers are part of the implementation (which
>> comprises C, POSIX plus GNU and Linux extensions), and only the GCC and
>> Glibc library components and their external names.
>>
>> Other libraries are third parties; the __ and _[A-Z] namespace
>> simply doesn't belong to them.
>>
>> C doesn't provide any special tools for the application developer and
>> third party code to avoid clashes among themselves.
>
> That’s true, but AFAICT it’s exactly what Lawrence is complaining about:
> there’s nothing in the language spec to help those thousand other
> libraries avoid name clashes.
>

No, it is /not/ what Lawrence is complaining about. He is complaining
about clashes within the reserved namespace, because he didn't
understand the difference between the library and headers that make up a
C implementation, and other libraries that he happens to have on the
system. It's an understandable confusion, since it is an overload of
the term "library". But hopefully he understands that now.

The limited support for avoiding name clashes in C (user-level C,
outside of the implementation internals) is certainly something that he
(or others) /could/ complain about. It is a well-known issue, and it's
a shame that the C standards committee have never dealt with it. I
don't see why the language could not adopt a simple "namespace" solution
that would hugely simplify avoiding identifier clashes. (It wouldn't
help for macros, but we have inline functions to handle many cases.)

Re: Word For Today: “Uglification”

<20240312174600.5b88613545da9f667e06a4c6@g{oogle}mail.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34307&group=comp.lang.c#34307

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: anton....@g{oogle}mail.com (Anton Shepelev)
Newsgroups: comp.lang.c
Subject: Re: Word For Today: “Uglification”
Date: Tue, 12 Mar 2024 17:46:00 +0300
Organization: A noiseless patient Spider
Lines: 19
Message-ID: <20240312174600.5b88613545da9f667e06a4c6@g{oogle}mail.com>
References: <uso6or$3t3jn$3@dont-email.me>
<usopec$4eob$1@dont-email.me>
<usort1$4t2r$1@dont-email.me>
<20240312003531.349@kylheku.com>
<wwvwmq7x4ex.fsf@LkoBDZeT.terraraq.uk>
<usp9m5$7it7$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="d13e3206328941c7d8e4f3573f34dc72";
logging-data="371448"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+JpJkjD+NEyi/xFCXJWkGTCxNqDO45CTg="
Cancel-Lock: sha1:yo4qGS74b55JER0UhHKIpNIW2Tg=
X-Newsreader: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32)
 by: Anton Shepelev - Tue, 12 Mar 2024 14:46 UTC

David Brown:

> The limited support for avoiding name clashes in C (user-
> level C, outside of the implementation internals) is
> certainly something that he (or others) /could/ complain
> about. It is a well-known issue, and it's a shame that
> the C standards committee have never dealt with it. I
> don't see why the language could not adopt a simple
> "namespace" solution that would hugely simplify avoiding
> identifier clashes. (It wouldn't help for macros, but we
> have inline functions to handle many cases.)

My hypothetical solution is to have a single function
returning a struct with pointers to all the public functions
of a module.

--
() ascii ribbon campaign -- against html e-mail
/\ www.asciiribbon.org -- against proprietary attachments

Re: Word For Today: “Uglification”

<uspqa4$bfao$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34308&group=comp.lang.c#34308

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (bart)
Newsgroups: comp.lang.c
Subject: Re: Word For Today: “Uglification”
Date: Tue, 12 Mar 2024 14:53:57 +0000
Organization: A noiseless patient Spider
Lines: 19
Message-ID: <uspqa4$bfao$1@dont-email.me>
References: <uso6or$3t3jn$3@dont-email.me> <usopec$4eob$1@dont-email.me>
<usort1$4t2r$1@dont-email.me> <20240312003531.349@kylheku.com>
<wwvwmq7x4ex.fsf@LkoBDZeT.terraraq.uk> <usp9m5$7it7$1@dont-email.me>
<20240312174600.5b88613545da9f667e06a4c6@g{oogle}mail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 12 Mar 2024 14:53:56 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="cc591688dbaf79a334a7a98b0e4256c3";
logging-data="376152"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/qGI/keEnrWFCHN+SQcIol"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:SyKFg5sPdVjDXdqeplZd2OnrSS0=
Content-Language: en-GB
In-Reply-To: <20240312174600.5b88613545da9f667e06a4c6@g{oogle}mail.com>
 by: bart - Tue, 12 Mar 2024 14:53 UTC

On 12/03/2024 14:46, Anton Shepelev wrote:
> David Brown:
>
>> The limited support for avoiding name clashes in C (user-
>> level C, outside of the implementation internals) is
>> certainly something that he (or others) /could/ complain
>> about. It is a well-known issue, and it's a shame that
>> the C standards committee have never dealt with it. I
>> don't see why the language could not adopt a simple
>> "namespace" solution that would hugely simplify avoiding
>> identifier clashes. (It wouldn't help for macros, but we
>> have inline functions to handle many cases.)
>
> My hypothetical solution is to have a single function
> returning a struct with pointers to all the public functions
> of a module.
>
What stops that function name clashing with the single function exported
from other people's modules?

Re: Word For Today: “Uglification”

<20240312180904.ac3a5856df424c396689db3e@g{oogle}mail.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34309&group=comp.lang.c#34309

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: anton....@g{oogle}mail.com (Anton Shepelev)
Newsgroups: comp.lang.c
Subject: Re: Word For Today: “Uglification”
Date: Tue, 12 Mar 2024 18:09:04 +0300
Organization: A noiseless patient Spider
Lines: 27
Message-ID: <20240312180904.ac3a5856df424c396689db3e@g{oogle}mail.com>
References: <uso6or$3t3jn$3@dont-email.me>
<usopec$4eob$1@dont-email.me>
<usort1$4t2r$1@dont-email.me>
<20240312003531.349@kylheku.com>
<wwvwmq7x4ex.fsf@LkoBDZeT.terraraq.uk>
<usp9m5$7it7$1@dont-email.me>
<20240312174600.5b88613545da9f667e06a4c6@g{oogle}mail.com>
<uspqa4$bfao$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="d13e3206328941c7d8e4f3573f34dc72";
logging-data="378183"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/spFp1VH7Pfs1j7be+gJEX7XvXvBXXAnI="
Cancel-Lock: sha1:CEhuMxleT98kD7vI5AP0N0hsR8k=
X-Newsreader: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32)
 by: Anton Shepelev - Tue, 12 Mar 2024 15:09 UTC

bart:
> Anton Shepelev:
> > David Brown:
> >
> > > The limited support for avoiding name clashes in C
> > > (user-level C, outside of the implementation
> > > internals) is certainly something that he (or others)
> > > /could/ complain about. It is a well-known issue, and
> > > it's a shame that the C standards committee have never
> > > dealt with it. I don't see why the language could not
> > > adopt a simple "namespace" solution that would hugely
> > > simplify avoiding identifier clashes. (It wouldn't
> > > help for macros, but we have inline functions to
> > > handle many cases.)
> >
> > My hypothetical solution is to have a single function
> > returning a struct with pointers to all the public
> > functions of a module.
>
> What stops that function name clashing with the single
> function exported from other people's modules?

A much lower probability.

--
() ascii ribbon campaign -- against html e-mail
/\ www.asciiribbon.org -- against proprietary attachments

Re: Word For Today: “Uglification”

<uspt5n$c2bg$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34311&group=comp.lang.c#34311

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (bart)
Newsgroups: comp.lang.c
Subject: Re: Word For Today: “Uglification”
Date: Tue, 12 Mar 2024 15:42:48 +0000
Organization: A noiseless patient Spider
Lines: 50
Message-ID: <uspt5n$c2bg$1@dont-email.me>
References: <uso6or$3t3jn$3@dont-email.me> <usopec$4eob$1@dont-email.me>
<usort1$4t2r$1@dont-email.me> <20240312003531.349@kylheku.com>
<wwvwmq7x4ex.fsf@LkoBDZeT.terraraq.uk> <usp9m5$7it7$1@dont-email.me>
<20240312174600.5b88613545da9f667e06a4c6@g{oogle}mail.com>
<uspqa4$bfao$1@dont-email.me>
<20240312180904.ac3a5856df424c396689db3e@g{oogle}mail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 12 Mar 2024 15:42:47 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="cc591688dbaf79a334a7a98b0e4256c3";
logging-data="395632"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/18lR80X5XugymIFmpC7GL"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:Qa+z5sztjkon5gJpUZlUbQeMxNY=
In-Reply-To: <20240312180904.ac3a5856df424c396689db3e@g{oogle}mail.com>
Content-Language: en-GB
 by: bart - Tue, 12 Mar 2024 15:42 UTC

On 12/03/2024 15:09, Anton Shepelev wrote:
> bart:
>> Anton Shepelev:
>>> David Brown:
>>>
>>>> The limited support for avoiding name clashes in C
>>>> (user-level C, outside of the implementation
>>>> internals) is certainly something that he (or others)
>>>> /could/ complain about. It is a well-known issue, and
>>>> it's a shame that the C standards committee have never
>>>> dealt with it. I don't see why the language could not
>>>> adopt a simple "namespace" solution that would hugely
>>>> simplify avoiding identifier clashes. (It wouldn't
>>>> help for macros, but we have inline functions to
>>>> handle many cases.)
>>>
>>> My hypothetical solution is to have a single function
>>> returning a struct with pointers to all the public
>>> functions of a module.
>>
>> What stops that function name clashing with the single
>> function exported from other people's modules?
>
> A much lower probability.
>

I tried my C compiler with a couple of open source projects recently
that both failed for the same mysterious reason.

It turned out that one of them used this line:

#include "string.h"

and the other used:

#include "malloc.h"

Notice they use "..." rather than <...>. These are not the standard
headers, but user-written headers with the same names. (My compiler
looks for them in the wrong order.)

People like reusing the same popular module names so much, they will
even use the names of standard headers! Any exported function name is
likely to be linked to the name of the module.

>>> returning a struct with pointers to all the public
>>> functions of a module.

There may be an additional clash-point with exposing the name of the struct.

Re: Word For Today: “Uglification”

<usptlp$c79g$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34312&group=comp.lang.c#34312

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: jameskuy...@alumni.caltech.edu (James Kuyper)
Newsgroups: comp.lang.c
Subject: Re: Word For Today: “Uglification”
Date: Tue, 12 Mar 2024 11:51:21 -0400
Organization: A noiseless patient Spider
Lines: 17
Message-ID: <usptlp$c79g$1@dont-email.me>
References: <uso6or$3t3jn$3@dont-email.me> <usopec$4eob$1@dont-email.me>
<usort1$4t2r$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 12 Mar 2024 15:51:21 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="1b2f7d6314d5bff909509365f5964211";
logging-data="400688"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18PZgDM0iki+n77T+s7Nw0DYRR52zQKCRA="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:in4yYt62FMzXuXutcH+5WCqeDpI=
Content-Language: en-US
In-Reply-To: <usort1$4t2r$1@dont-email.me>
 by: James Kuyper - Tue, 12 Mar 2024 15:51 UTC

On 3/12/24 02:14, Lawrence D'Oliveiro wrote:
....
> The problem I have with that is the singular form of “library”. In a
> typical Linux distro, you could have thousands of libraries installed.
> I just did this command on my Debian system:
>
> dpkg-query -l lib*dev | wc -l
>
> and the answer came back “1037”. The idea that a C-language
> implementation and run-time environment is any sense monolithic seems
> hopelessly out of touch.

It was never monolithic, any more than talking about the United States
implies that the United States is a monolithic entity. The standard
allows an implementation to have many separate parts, by failing to
prohibit such a structure - but everything it says about one is about
the implementation as a whole, not the individual parts.

Re: Word For Today: “Uglification”

<20240312113558.815@kylheku.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34314&group=comp.lang.c#34314

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 433-929-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c
Subject: Re: Word For Today: “Uglification”
Date: Tue, 12 Mar 2024 18:42:05 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 48
Message-ID: <20240312113558.815@kylheku.com>
References: <uso6or$3t3jn$3@dont-email.me> <usopec$4eob$1@dont-email.me>
<usort1$4t2r$1@dont-email.me> <20240312003531.349@kylheku.com>
<wwvwmq7x4ex.fsf@LkoBDZeT.terraraq.uk> <usp9m5$7it7$1@dont-email.me>
<20240312174600.5b88613545da9f667e06a4c6@g{oogle}mail.com>
<uspqa4$bfao$1@dont-email.me>
Injection-Date: Tue, 12 Mar 2024 18:42:05 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="103d6665e02695c45444ee5fbac9bd46";
logging-data="476480"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+s4OXsgtEEYA/KCDLOFATX7zvAkonY8NA="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:P7MVSqo4ejVgs/f690GN5G9DQZo=
 by: Kaz Kylheku - Tue, 12 Mar 2024 18:42 UTC

On 2024-03-12, bart <bc@freeuk.com> wrote:
> On 12/03/2024 14:46, Anton Shepelev wrote:
>> David Brown:
>>
>>> The limited support for avoiding name clashes in C (user-
>>> level C, outside of the implementation internals) is
>>> certainly something that he (or others) /could/ complain
>>> about. It is a well-known issue, and it's a shame that
>>> the C standards committee have never dealt with it. I
>>> don't see why the language could not adopt a simple
>>> "namespace" solution that would hugely simplify avoiding
>>> identifier clashes. (It wouldn't help for macros, but we
>>> have inline functions to handle many cases.)
>>
>> My hypothetical solution is to have a single function
>> returning a struct with pointers to all the public functions
>> of a module.
>>
> What stops that function name clashing with the single function exported
> from other people's modules?

There are multiple possible answers here.

One is that even if such functions have to be uniquely named, that is a
lesser burden than all API functions having to be uniquely named.
The probability of a clash is reduced, and at most one function
has to be renamed if it occurs.

There are ways that this single function can have the same name
in every component.

For instance, under Microsoft COM, COM DLLs provide well-known
functions like DllGetClassObject, DllRegisterServer and
DllUnregisterServer.

These don't clash since they are in different DLLs.

An appliation queries for the COM object using its class ID,
which is a GUID. That must be unique. DllRegisterServer registers
it in the registry.

Variations on this theme can be done in any system that has dynamic
libraries or loadable modules.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Re: Word For Today: “Uglification”

<20240312114213.182@kylheku.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34315&group=comp.lang.c#34315

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 433-929-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c
Subject: Re: Word For Today: “Uglification”
Date: Tue, 12 Mar 2024 18:50:14 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 74
Message-ID: <20240312114213.182@kylheku.com>
References: <uso6or$3t3jn$3@dont-email.me> <usopec$4eob$1@dont-email.me>
<usort1$4t2r$1@dont-email.me> <20240312003531.349@kylheku.com>
<wwvwmq7x4ex.fsf@LkoBDZeT.terraraq.uk> <usp9m5$7it7$1@dont-email.me>
<20240312174600.5b88613545da9f667e06a4c6@g{oogle}mail.com>
<uspqa4$bfao$1@dont-email.me>
<20240312180904.ac3a5856df424c396689db3e@g{oogle}mail.com>
<uspt5n$c2bg$1@dont-email.me>
Injection-Date: Tue, 12 Mar 2024 18:50:14 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="103d6665e02695c45444ee5fbac9bd46";
logging-data="476480"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/HmxkGJbQI0w8o9O0hDFmuuPZv7iefHiM="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:9SaGteUIVrdbJ0BWh91/XWVV3Zg=
 by: Kaz Kylheku - Tue, 12 Mar 2024 18:50 UTC

On 2024-03-12, bart <bc@freeuk.com> wrote:
> On 12/03/2024 15:09, Anton Shepelev wrote:
>> bart:
>>> Anton Shepelev:
>>>> David Brown:
>>>>
>>>>> The limited support for avoiding name clashes in C
>>>>> (user-level C, outside of the implementation
>>>>> internals) is certainly something that he (or others)
>>>>> /could/ complain about. It is a well-known issue, and
>>>>> it's a shame that the C standards committee have never
>>>>> dealt with it. I don't see why the language could not
>>>>> adopt a simple "namespace" solution that would hugely
>>>>> simplify avoiding identifier clashes. (It wouldn't
>>>>> help for macros, but we have inline functions to
>>>>> handle many cases.)
>>>>
>>>> My hypothetical solution is to have a single function
>>>> returning a struct with pointers to all the public
>>>> functions of a module.
>>>
>>> What stops that function name clashing with the single
>>> function exported from other people's modules?
>>
>> A much lower probability.
>>
>
> I tried my C compiler with a couple of open source projects recently
> that both failed for the same mysterious reason.
>
> It turned out that one of them used this line:
>
> #include "string.h"
>
> and the other used:
>
> #include "malloc.h"

In the TXR project, I have a "signal.h" header, which must not resolve
to <signal.h>. I also have "time.h" and "termios.h", "glob.h",
"regex.h", "alloca.h".

Choosing header names that are distinct from an implementation's
headers is:

1) unnecessary due the local-first search strategy of #include "..."

2) a fool's errand.

Regarding (2), no name that you choose is guaranteed not to be identical
to something in the implementation! Suppose I panic and rename
my "time.h" to "foo.h". Who is to say that some implementation doesn't
have a <foo.h> header?

There is no such rule that when you name a "whatever.h", you must
ensure there does not exist a <whatever.h>.

> People like reusing the same popular module names so much, they will
> even use the names of standard headers!

Sometimes deliberately so. Why did I call that header "termios.h"
is that the module is relates to is related to the POSIX termios;
the source file is called termios.c and includes <termios.h> as
well as its own "termios.h". This makes things readable; someone
looking at the directory listing can guess that these files
constitute a module which wraps termios.

Any other naming would obscure that to some degree, other than
perhaps longer names that contain "termios" as a substring.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Re: Word For Today: “Uglification”

<usqhjg$gpvk$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34318&group=comp.lang.c#34318

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo...@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.lang.c
Subject: Re: Word For Today: “Uglification”
Date: Tue, 12 Mar 2024 21:31:28 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 6
Message-ID: <usqhjg$gpvk$2@dont-email.me>
References: <uso6or$3t3jn$3@dont-email.me> <usopec$4eob$1@dont-email.me>
<usort1$4t2r$1@dont-email.me> <usptlp$c79g$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 12 Mar 2024 21:31:28 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="11b38f0fdef8c619d895dc1d0c253c52";
logging-data="550900"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/fEuM2H20lJ2BpK3dehykx"
User-Agent: Pan/0.155 (Kherson; fc5a80b8)
Cancel-Lock: sha1:6WohfdDGKLB3xYphSJpZCpDQy2c=
 by: Lawrence D'Oliv - Tue, 12 Mar 2024 21:31 UTC

On Tue, 12 Mar 2024 11:51:21 -0400, James Kuyper wrote:

> ... everything it says about one is about
> the implementation as a whole, not the individual parts.

You don’t see the problem with trying avoid clashes between those parts?

Re: Word For Today: “Uglification”

<pan$dde14$ad0cc54e$43de28e$c5b056a4@invalid.invalid>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34319&group=comp.lang.c#34319

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!bluemanedhawk.eternal-september.org!.POSTED!not-for-mail
From: bluemane...@invalid.invalid (Blue-Maned_Hawk)
Newsgroups: comp.lang.c
Subject: Re: Word For Today: “Uglification”
Date: Tue, 12 Mar 2024 22:07:10 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 19
Message-ID: <pan$dde14$ad0cc54e$43de28e$c5b056a4@invalid.invalid>
References: <uso6or$3t3jn$3@dont-email.me> <usopec$4eob$1@dont-email.me>
<usort1$4t2r$1@dont-email.me> <20240312003531.349@kylheku.com>
<wwvwmq7x4ex.fsf@LkoBDZeT.terraraq.uk> <usp9m5$7it7$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 12 Mar 2024 22:07:10 -0000 (UTC)
Injection-Info: bluemanedhawk.eternal-september.org; posting-host="c8566f52f3b01ded51fab4df8d08e22a";
logging-data="565012"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/ER8XpAKGqnI+M62QLSMr9yq/p5aLRm7A="
User-Agent: Pan/0.154 (Izium; 517acf4)
Cancel-Lock: sha1:AVKD/Oqcvd0snK8kgHMX3JzF1hk=
Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAIAAADYYG7QAAACh0lEQVRYw71Z21bD
MAzzevbfkr4cHjrSXJyL044+MDa6WLEl2SkvkrZ1AbAvXO+bUGSCPYnsuIVGMpm
ZLnjX718GhAKNsp8lON2F9VrhELwIgJlBepkZjA78rVK+FkmNhEJK76UsJlz8+E
rJsjrpYouhLo/SC6qPHgakFOR8wV9+8rCfO/I/oVnmUZUp42/LW2XkLj9TCFNM9
jp5g2EmHZgpYZjCOkYU7sXVogRylJqpdggoFLG1g09Flah/7kErCxzR9HgXPYsq
0glb9cxjIz2Vsk9AmAoCSxECpD713joMKjQqLAtmMqJmXjdVvlMnMQCVITotJd1
z+fh1f1NNo+vuc1KnhWUmY7t03vydTud9BbXCtN3L2PL3bK7JCNG0GHzuZxafyB
fxevCxpm1vrwZltqw6SILCcdoCE6PGQC8wZWDA9Or7Qp5s3lAZezys0nDazs9S9
R0TjwEiksRxLkNPC1NMMWPs1bj0Ei0Yuo+JVtFLuzP1NRJ16qXWN8DhhtmS4PDg
O6mqRxs4bEJrYt087mSIow/1VzW2oFlMQuiuIy/KsUagvhdw6hSjJGlIavbLF8x
j3X47bccLcUSi0dkWh1nUZNhANT1tHKUXrNxNLbd9KPb9wDDVrKwmPQMOPQ1oy6
k5I1DwzDeRJd3jVIhDAUxq3ngzJG4CCkNXZxZVMcjefoK2J0gUY2S3rxz/RuTFx
2zHd9U+obimJXMG4edsk/2j5pTU5G1MmzbRLxkfq5EiT1GGsidvMGzi+1goGb2l
GCrN+nGnV8xj3q3JLRDVPL96vUc7Z4aJ3TN1mVqWAMJMfG+Jxh6TQqP+92iZkCU
xtglds1AB6r0aiSHKcnFck+p/c/0CbacFLQcajGcAAAAASUVORK5CYII=
X-Face: Taumatawhakatangihangakoauauotamateaturipukakapikimaungahoronuku
pokaiwhenuakitanatahu
 by: Blue-Maned_Hawk - Tue, 12 Mar 2024 22:07 UTC

David Brown wrote:

> The limited support for avoiding name clashes in C (user-level C,
> outside of the implementation internals) is certainly something that he
> (or others) /could/ complain about. It is a well-known issue, and it's
> a shame that the C standards committee have never dealt with it. I
> don't see why the language could not adopt a simple "namespace" solution
> that would hugely simplify avoiding identifier clashes. (It wouldn't
> help for macros, but we have inline functions to handle many cases.)

Many libraries put a prefix on their identifiers as a form of
psuedonamespacing.

--
Blue-Maned_Hawk│shortens to Hawk│/blu.mɛin.dʰak/│he/him/his/himself/Mr.
blue-maned_hawk.srht.site
The law prohibits underwater smoking!

Re: Word For Today: “Uglification”

<87h6hb851o.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34320&group=comp.lang.c#34320

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: Word For Today: “Uglification”
Date: Tue, 12 Mar 2024 15:21:39 -0700
Organization: None to speak of
Lines: 37
Message-ID: <87h6hb851o.fsf@nosuchdomain.example.com>
References: <uso6or$3t3jn$3@dont-email.me> <usopec$4eob$1@dont-email.me>
<usort1$4t2r$1@dont-email.me> <usptlp$c79g$1@dont-email.me>
<usqhjg$gpvk$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: dont-email.me; posting-host="de8f53c78bf32f77c14d770a36ea4d62";
logging-data="574840"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/KDppNMeZKzmRMrnUBJhWe"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:5JUVNPg+uWUONN53/O3qv5A71dg=
sha1:S4AGVQ2ZxcuTzNOlkh/6MTb+HKI=
 by: Keith Thompson - Tue, 12 Mar 2024 22:21 UTC

Lawrence D'Oliveiro <ldo@nz.invalid> writes:
> On Tue, 12 Mar 2024 11:51:21 -0400, James Kuyper wrote:
>> ... everything it says about one is about
>> the implementation as a whole, not the individual parts.
>
> You don’t see the problem with trying avoid clashes between those parts?

I think everyone is aware of the problem. Was that your point?

The standard reserves certain identifiers for use by the implementation.
The implementation includes the standard library described in section 7,
not to all the libraries that happen to be installed on a system; those
libraries, as far as the standard is concerned, are just user code.
Third-party libraries are, for example, not permitted to define
identifiers starting with two underscores, because those same
identifiers might be used by the standard library or by the compiler.
This is typically not enforced, but using such an identifier in code
that's not part of the standard library has undefined behavior. (I've
seen plenty of such identifiers in third-party code; it typically
doesn't cause a problem in practice unless there's an actual collision.)

If your point is that "name collisions are a problem", of course that's
true. Name collisions within the standard library are typically not a
problem. The standard library is typically provided either by a single
implementer or by a few implementers who are very careful to avoid
collisions.

C doesn't provide a namespace facility like C++'s, so implementers of
third-party libraries might use identifier prefixes or other tricks to
avoid collisions.

Again, have you actually seen name collision problems in the real world?

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Medtronic
void Void(void) { Void(); } /* The recursive call of the void */

Re: Word For Today: “Uglification”

<usql0p$hk2k$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34321&group=comp.lang.c#34321

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (bart)
Newsgroups: comp.lang.c
Subject: Re: Word For Today: “Uglification”
Date: Tue, 12 Mar 2024 22:29:45 +0000
Organization: A noiseless patient Spider
Lines: 82
Message-ID: <usql0p$hk2k$1@dont-email.me>
References: <uso6or$3t3jn$3@dont-email.me> <usopec$4eob$1@dont-email.me>
<usort1$4t2r$1@dont-email.me> <20240312003531.349@kylheku.com>
<wwvwmq7x4ex.fsf@LkoBDZeT.terraraq.uk> <usp9m5$7it7$1@dont-email.me>
<20240312174600.5b88613545da9f667e06a4c6@g{oogle}mail.com>
<uspqa4$bfao$1@dont-email.me>
<20240312180904.ac3a5856df424c396689db3e@g{oogle}mail.com>
<uspt5n$c2bg$1@dont-email.me> <20240312114213.182@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 12 Mar 2024 22:29:45 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="cc591688dbaf79a334a7a98b0e4256c3";
logging-data="577620"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+wyB8kujDW4pGXfoX5kjsh"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:6NmJW5uboW18aJL6X9C8DLajt+w=
In-Reply-To: <20240312114213.182@kylheku.com>
Content-Language: en-GB
 by: bart - Tue, 12 Mar 2024 22:29 UTC

On 12/03/2024 18:50, Kaz Kylheku wrote:
> On 2024-03-12, bart <bc@freeuk.com> wrote:

>> I tried my C compiler with a couple of open source projects recently
>> that both failed for the same mysterious reason.
>>
>> It turned out that one of them used this line:
>>
>> #include "string.h"
>>
>> and the other used:
>>
>> #include "malloc.h"
>
> In the TXR project, I have a "signal.h" header, which must not resolve
> to <signal.h>. I also have "time.h" and "termios.h", "glob.h",
> "regex.h", "alloca.h".
>
> Choosing header names that are distinct from an implementation's
> headers is:
>
> 1) unnecessary due the local-first search strategy of #include "..."
>
> 2) a fool's errand.

It's confusing. So "string.h" means the standard header, so it is the
same as <string.h>, unless it happens to find a file called string.h
amongst the project files.

That is undesirable, unless you specifically want to shadow the standard
headers. In the examples I saw, that was not the case.

> Regarding (2), no name that you choose is guaranteed not to be identical
> to something in the implementation! Suppose I panic and rename
> my "time.h" to "foo.h". Who is to say that some implementation doesn't
> have a <foo.h> header?

The C implementation? Surely that will list all the system headers that
it provides; it looks quite easy to avoid a clash!

>
> There is no such rule that when you name a "whatever.h", you must
> ensure there does not exist a <whatever.h>.

You mean that programs should be allowed to do this:

#include <string.h>
#include "string.h"

With the two headers doing totally different things.

I can guess the reasons why such a rule doesn't exist, because so many
programs just carelessly used "..." instead of <...>, and they would all
break if it was imposed.

>> People like reusing the same popular module names so much, they will
>> even use the names of standard headers!
>
> Sometimes deliberately so. Why did I call that header "termios.h"
> is that the module is relates to is related to the POSIX termios;
> the source file is called termios.c and includes <termios.h> as
> well as its own "termios.h". This makes things readable; someone
> looking at the directory listing can guess that these files
> constitute a module which wraps termios.

So, is that /your/ file termios.c, or the one that implements the POSIX
termios code?

If it is your file, does it wrap the standard one, or replace it?
Generally if you want to wrap X, you call the wrapper Y; having both
called X is troublesome. Supposed somebody wanted to wrap your X, and
they wanted theirs called X too.

Suppose you want two different wrappers for X...

> Any other naming would obscure that to some degree, other than
> perhaps longer names that contain "termios" as a substring.

Re: Word For Today: “Uglification”

<878r2n839m.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34324&group=comp.lang.c#34324

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: Word For Today: “Uglification”
Date: Tue, 12 Mar 2024 16:00:05 -0700
Organization: None to speak of
Lines: 120
Message-ID: <878r2n839m.fsf@nosuchdomain.example.com>
References: <uso6or$3t3jn$3@dont-email.me> <usopec$4eob$1@dont-email.me>
<usort1$4t2r$1@dont-email.me> <20240312003531.349@kylheku.com>
<wwvwmq7x4ex.fsf@LkoBDZeT.terraraq.uk> <usp9m5$7it7$1@dont-email.me>
<20240312174600.5b88613545da9f667e06a4c6@g{oogle}mail.com>
<uspqa4$bfao$1@dont-email.me>
<20240312180904.ac3a5856df424c396689db3e@g{oogle}mail.com>
<uspt5n$c2bg$1@dont-email.me> <20240312114213.182@kylheku.com>
<usql0p$hk2k$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="3a33dee2b2d0e1e9aaa54021fdfdfa61";
logging-data="590682"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/nH06j5hPGmWKFfLOzmelP"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:8r2Qy/IF0xqslMXuFJD99bv0bSY=
sha1:rXfXNeZ86J4B0TUO9ZZUWEFTcW8=
 by: Keith Thompson - Tue, 12 Mar 2024 23:00 UTC

bart <bc@freeuk.com> writes:
> On 12/03/2024 18:50, Kaz Kylheku wrote:
>> On 2024-03-12, bart <bc@freeuk.com> wrote:
>>> I tried my C compiler with a couple of open source projects recently
>>> that both failed for the same mysterious reason.
>>>
>>> It turned out that one of them used this line:
>>>
>>> #include "string.h"
>>>
>>> and the other used:
>>>
>>> #include "malloc.h"

Note that malloc.h is not a standard header.

Apparently this helped you find and fix a bug in your compiler.

>> In the TXR project, I have a "signal.h" header, which must not
>> resolve to <signal.h>. I also have "time.h" and "termios.h",
>> "glob.h", "regex.h", "alloca.h".
>> Choosing header names that are distinct from an implementation's
>> headers is:
>> 1) unnecessary due the local-first search strategy of #include "..."
>> 2) a fool's errand.
>
> It's confusing. So "string.h" means the standard header, so it is the
> same as <string.h>, unless it happens to find a file called string.h
> amongst the project files.

Yes. But it doesn't "happen to" find a file called string.h; that file
is part of the project. You've just explained it correctly, so I'm not
sure what confuses you.

> That is undesirable, unless you specifically want to shadow the
> standard headers. In the examples I saw, that was not the case.

You didn't mention that. If you'd tell us what project you're talking
about, maybe we could discuss it. Perhaps

>> Regarding (2), no name that you choose is guaranteed not to be identical
>> to something in the implementation! Suppose I panic and rename
>> my "time.h" to "foo.h". Who is to say that some implementation doesn't
>> have a <foo.h> header?
>
> The C implementation? Surely that will list all the system headers
> that it provides; it looks quite easy to avoid a clash!
>
>> There is no such rule that when you name a "whatever.h", you must
>> ensure there does not exist a <whatever.h>.
>
> You mean that programs should be allowed to do this:
>
> #include <string.h>
> #include "string.h"
>
> With the two headers doing totally different things.

I'm not going to say that programs *should* be allowed to do that, but
the fact is that they *are* allowed to do that.

Read section 6.10.2 of the standard. It describes the search rules for
the #include directive.

To summarize, #include <foo.h> searches for a header (probably but not
necessarily a file) identified by foo.h. #include "foo.h" searches for
a *file* called foo.h, and if that fails it then searches for a header
identified by <foo.h>. The sequences for both searches are
implementation-defined.

(The standard does mention the possibility that the "foo.h" search is
not supported. Any such implementation would not be able to handle
user-defined header files; perhaps they would have to be installed as
"headers" somehow. In every implementation I know about, the compiler
will *at least* find the foo.h file if it's in the same directory as the
file that includes it. And if an implementation is able to handle
#include "foo.h", it can also handle #include "string.h".)

If you provide a file called "string.h" as part of your project, and set
up the implementation-defined search paths correctly, then
#include "string.h"
refers to the file in your project, and
#include <string.h>
refers to the standard header.

Having <string.h> and "string.h" do "totally different things" would
perhaps be unwise, but nothing in the standard forbids it. (I wonder
if you think it could or should.)

> I can guess the reasons why such a rule doesn't exist, because so many
> programs just carelessly used "..." instead of <...>, and they would
> all break if it was imposed.

No they wouldn't -- or rather, no they don't. A program that carelessly
uses #include "string.h" to refer to the standard header will work just
fine as long as the project doesn't have a file by that name. The
initial search will fail, and then it will find the standard header.
Certainly #include <string.h> is better style. And a program that
deliberately uses #include "string.h" to refer to its own file by that
name, it will work correctly as long as the search path is set up
correctly.

I'm personally not entirely comfortable with mirroring standard header
names, like using #include "string.h" to use a header file that wraps
the standard header <string.h>. My first thought on seeing that would
be to think that the author should have used <> rather than "". There's
also some risk that if you don't set up the search path correctly,
#include "string.h" could refer to the standard header. But I can see
how it would be useful, and nothing in the language forbids it. If a
project uses such a scheme consistently, I have no problem with it,
beyond a brief moment of "Oh, that's what you're doing".

I might prefer #include "string_wrapper.h".

[snip]

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Medtronic
void Void(void) { Void(); } /* The recursive call of the void */

Re: Word For Today: “Uglification”

<usqnji$i40m$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34325&group=comp.lang.c#34325

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo...@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.lang.c
Subject: Re: Word For Today: “Uglification”
Date: Tue, 12 Mar 2024 23:13:55 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 9
Message-ID: <usqnji$i40m$2@dont-email.me>
References: <uso6or$3t3jn$3@dont-email.me> <usopec$4eob$1@dont-email.me>
<usort1$4t2r$1@dont-email.me> <20240312003531.349@kylheku.com>
<wwvwmq7x4ex.fsf@LkoBDZeT.terraraq.uk>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 12 Mar 2024 23:13:55 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="71ae5262ccd34dd01afa45cb3ad06860";
logging-data="593942"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Wv0cAOGu+UMLN6WG7WNE8"
User-Agent: Pan/0.155 (Kherson; fc5a80b8)
Cancel-Lock: sha1:9s28Nr3HXoI7Dy53Z7FLlWPCbJY=
 by: Lawrence D'Oliv - Tue, 12 Mar 2024 23:13 UTC

On Tue, 12 Mar 2024 08:03:50 +0000, Richard Kettlewell wrote:

> That’s true, but AFAICT it’s exactly what Lawrence is complaining about:
> there’s nothing in the language spec to help those thousand other
> libraries avoid name clashes.

My specific complaint was about temporary names being used internal to
library macros. It’s a problem that is essentially impossible to solve
with string-based macro processors.

Pages:123
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor