[PATCH v5] algol68: Add allocation function for leaf objects
Jose E. Marchesi
jemarch@gnu.org
Mon Jan 19 09:43:10 GMT 2026
> On Sun, Jan 18, 2026, at 11:34 AM, Jose E. Marchesi wrote:
>
>>> tree
>>> -a68_lower_malloc (tree type, tree size)
>>> +a68_lower_malloc (MOID_T *m, tree size)
>>> {
>>> + tree type = CTYPE (m);
>>> + a68_libcall_fn libcall
>>> + = HAS_REFS (m) ? A68_LIBCALL_MALLOC : A68_LIBCALL_MALLOC_LEAF;
>>
>> Row descriptors also have pointers.
>>
>> I think you want:
>>
>> HAS_REFS (m) || HAS_ROWS (m) ? A68_LIBCALL_MALLOC : A68_LIBCALL_MALLOC_LEAF
>
> I didn't use HAS_ROW because the descriptor and the element array are
> allocated separately. So I thought it wasn't strictly necessary but now
> I'm thinking that if I use malloc_leaf for the descriptor ther GC may free
> the array prematurely.
Yes the descriptor has a pointer to the data.
>>> +static bool
>>> +is_mode_has_refs (MOID_T *m)
>>> +{
>>> + if (IS_ROW (m) || IS_FLEX (m))
>>> + return HAS_REFS (m) = is_mode_has_refs (SUB (m));
>>
>>
>> I would prefer:
>>
>> {
>> HAS_REFS (m) = is_mode_has_refs (m);
>> return HAS_REFS (m);
>>
>> }
>>
>> But if you must, please use parentheses:
>>
>> return (HAS_REFS (m) = is_mode_has_refs (SUB (m)));
>>
>> The GCS requires this, and in fact I expect GCC will give you a warning
>> otherwise..
>
> The 2-line version looks good.
>
> Thanks for the review. It feels like we're getting there and I'm
> learning a lot about the front end.
Very good!
Thank you for doing this.
More information about the Algol68
mailing list