Path: csiph.com!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Tim Rentsch
Newsgroups: comp.lang.c
Subject: Re: Why does C allow structs to have a tag?
Date: Thu, 24 Jun 2021 10:33:01 -0700
Organization: A noiseless patient Spider
Lines: 25
Message-ID: <867dijb22a.fsf@linuxsc.com>
References:
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: reader02.eternal-september.org; posting-host="5f9785b3afd09fb507884e20b2dfc5bb"; logging-data="11437"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+OPAIGgOmt97cJduYghVoeoGareclo8r4="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:5hUtBIVh2x8RljFsr13eqqrb4PM= sha1:plxOjYSL44eCSM18ssE0KGIXQy0=
Xref: csiph.com comp.lang.c:161483
John Bode writes:
[...]
> To reiterate a point I make a lot - typedef on its own creates leaky
> abstractions. If I need to know that I have to use the `.` or `->`
> operator on something, I'd rather have it declared as `struct A foo;` or
> `struct B *ptr;` instead of a type name that doesn't convey struct-ness
> at all. Same reason I don't like it when people hide pointers behind
> typedefs - I once spent half a day chasing my tail because somebody
> created a typedef name for a pointer type and used that as a template
> parameter for a vector in C++, such that when I was using an iterator
> I needed to write
>
> (*it)->do_something();
>
> However, since the typedef name didn't indicate pointer-ness *at all*, I
> wound up writing
>
> it->do_something();
>
> and g++ vomited up hundreds of incomprehensible error messages that
> basically boiled down to "you need to use a * here, dummy".
Sounds to me like the culprit is C++, not typedefs.