From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Philipp Stephani
On 10/04/2015 02:41 AM, Philipp Stephani wrote:
>=C2=A0 =C2=A0 =C2=A0>
>=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> I think it's important that this is a poin= ter to a struct (for type
>=C2=A0 =C2=A0 =C2=A0> safety and size correctness) rather than just = an arbitrary type.
>
>=C2=A0 =C2=A0 =C2=A0A typedef is exactly as typesafe. The question of w= hether to use a
>=C2=A0 =C2=A0 =C2=A0struct or a typedef is aesthetic. I strongly prefer= a typedef, just like
>=C2=A0 =C2=A0 =C2=A0pthreads, and I believe that the people who advocat= e using structs
>=C2=A0 =C2=A0 =C2=A0directly are simply wrong.
>
>
> Ah, I'm not against the typedef, I'm just asking whether you w= ould make
> it part of the API contract that it's a typedef of a struct pointe= r, or
> whether it can be any type.
The problem with defining it as a pointer type is that NULL is now the
invalid sentinel value, which seems incompatible with both making this
thing literally a Lisp_Object and Qnil having all zero bits.
That's why I strongly prefer making emacs_value a _pointer_ to a
Lisp_Object, where we store the Lisp_Object in an array owned by the
emacs_env. This way, allocating local values is very cheap.