Subject: bug#69749: (bindat-type sint 32 t) -> unbound variable bitlen

From: Stefan Monnier <[email-masked]>
Date: Fri, 15 Mar 2024 12:51:36 -0400

>> Your code ends up (via the `sint` of `bindat-type`) relying on the
>> `lexical-binding` dialect of ELisp, which is enabled by default in
>> `ielm` but not in your file.
> Indeed, thanks for the fix.
> Perhaps it would be useful for the bindat-type macro to emit a warning when
> it is running in the dynamic-binding dialect (at least for the types that
> require lexical binding)?

Agreed.  I just pushed a corresponding patch to `master`.
It impacts only `sint` (among the predefined types).

> This would have no runtime cost when byte-compiled or native-compiled,
> I assume.

The patch I installed indeed doesn't impact the performance of the code.
The underlying detail which requires `lexical-binding` to be active does
cause the code for `sint` to be significantly less efficient than that
for `uint`, tho, so if performance is important, you may prefer to use
`uint` and do the conversion to a signed integer manually elsewhere. 🙁

        Stefan