Subject: Re: bug#76573: 30.1; native compilation fails for record inside function

From: Andrea Corallo <[email-masked]>
Date: Tue, 29 Apr 2025 17:45:44 -0400

Eli Zaretskii <[email-masked]> writes:

>> From: Lin Jian <[email-masked]>
>> Cc: [email-masked],  [email-masked]
>> Date: Sat, 26 Apr 2025 17:06:48 +0800
>> 
>> Eli Zaretskii <[email-masked]> writes:
>> 
>> > > 4. It is not clear how to fix this error.
>> > Define the type, of course.
>> 
>> > > It would be even better to mention how to fix this error.
>> > Quite obviously, to fix the error, the Lisp program should define the
>> > type.
>> 
>> Sorry, I should have been more clear.  By how to fix this error, I mean
>> how to define the type.
>> 
>> Maybe it is just misohena[1] and me, but it is not clear to us how to
>> define the type.  Could you point us to the related doc?  Thanks.
>
> AFAIU, valid types are either a primitive type (so you can only create
> new types by changing the C code), or you could use make-record to
> make a record whose first slot specifies the type.
>
> Andrea, am I right?

In my understanding 'record' and 'make-record' are the low level
primitives to create records, but in order to _declare_ a new type to
the system the users should use 'cl-defstruct' or 'defclass'.

My idea is from the reading of the manual: "The purpose of records is to
allow programmers to create objects with new types that are not built
into Emacs. They are used as the underlying representation of
cl-defstruct and defclass instances."

In case we want to allow for compiling calls to 'record' or
'make-record' with types not declared through 'cl-defstruct' or
'defclass' we should remove the compiler error and probably make it a
warning, shouldn't be a big deal.