From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Philipp Stephani
On 09/13/2015 07:27 AM, Philipp Stephani wrote:
> Daniel Colascione <dancol@dancol.org <mailto:dancol@dancol.org>> schrieb
> am So., 13. Sep. 2015 um 16:15 Uhr:
>
>=C2=A0 =C2=A0 =C2=A0On 09/13/2015 06:04 AM, Philipp Stephani wrote:
>=C2=A0 =C2=A0 =C2=A0> Daniel Colascione <dancol@dancol.org <mailto:dancol@dancol.org>
>=C2=A0 =C2=A0 =C2=A0<mailto:dancol@dancol.org <mailto:dancol@dancol.org>>> schrieb
>=C2=A0 =C2=A0 =C2=A0> am So., 15. Feb. 2015 um 21:21 Uhr:
>=C2=A0 =C2=A0 =C2=A0>
>=C2=A0 =C2=A0 =C2=A0>=C2=A0 =C2=A0 =C2=A0 =C2=A0typedef struct emacs= _value_tag* emacs_value;
>=C2=A0 =C2=A0 =C2=A0>
>=C2=A0 =C2=A0 =C2=A0>
>=C2=A0 =C2=A0 =C2=A0> Would it make sense to not use a typedef here?= Using a typedef means
>=C2=A0 =C2=A0 =C2=A0> that the type including its size is opaque and= subject to change,
>=C2=A0 =C2=A0 =C2=A0which
>=C2=A0 =C2=A0 =C2=A0> can break ABI compatibility. I'd rather ha= ve something like:
>=C2=A0 =C2=A0 =C2=A0>
>=C2=A0 =C2=A0 =C2=A0> struct emacs_value {
>=C2=A0 =C2=A0 =C2=A0>=C2=A0 =C2=A0// contains private fields
>=C2=A0 =C2=A0 =C2=A0> };
>=C2=A0 =C2=A0 =C2=A0>
>=C2=A0 =C2=A0 =C2=A0> and then pass /struct emacs_value*/ around.
>
>=C2=A0 =C2=A0 =C2=A0You may have missed the "*" in the typede= f. The difference is stylistic.
>=C2=A0 =C2=A0 =C2=A0There's no difference between foo and bar here.=
>
>=C2=A0 =C2=A0 =C2=A0typedef struct valuex* value;
>=C2=A0 =C2=A0 =C2=A0void foo(struct valuex* x);
>=C2=A0 =C2=A0 =C2=A0void bar(value y);
>
>=C2=A0 =C2=A0 =C2=A0I find the typedef much more readable, however.
>
>
> There's no difference in your design, but using a typedef makes it=
> possible to use a non-pointer type without changing the API in obvious=
> ways.
> E.g. Linus is strongly against such
> typedefs: http://lkml.iu.edu/hypermai= l/linux/kernel/0206.1/0402.html
Linus is also against integer overflow checking. So what? I can't stand=
argumentum ad Linus.
I still find the typedef more readable, because to users, emacs_value is
an opaque type, and the fact that we implement it as a pointer is
irrelevant.