[PATCH RFC v3] algol68: Add allocation function for leaf objects

Pietro Monteiro pietro.gcc@sociotechnical.xyz
Thu Jan 15 16:37:14 GMT 2026


On Thu, Jan 15, 2026, at 6:17 AM, Jose E. Marchesi wrote:
>> On Wed, Jan 14, 2026, at 5:54 PM, Pietro Monteiro wrote:
...
>> +/* Whether mode has ref.  */
>> +
>> +static bool
>> +is_mode_has_ref (MOID_T *m)
>> +{
>> +  if (IS_STRUCT (m) || IS_UNION(m))
>> +    {
>> +      bool k = false;
>> +
>> +      for (PACK_T *p = PACK (m); p != NO_PACK && k == false; FORWARD (p))
>> +	{
>> +	  HAS_REFS (MOID (p)) = is_mode_has_ref (MOID (p));
>> +	  k |= (HAS_REFS (MOID (p)));
>> +	}
>> +      return k;
>> +    }
>> +  else
>> +    return (HAS_REFS (m) || IS_REF (m));
>> +}
>> +
>
>
> Don't you have to cover row modes (and flex) as well?  A flex has refs
> if SUB (m) has refs, and the same applies to rows.

Nice catch. I think I also need to remove the "&& k == false" from the
struct/union loop.

...

>> +#define IS_LEAF(m) (!HAS_REFS (m) && !HAS_ROWS (m))
>
> I think at this point this macro can go away.  The logic !HAS_REFS &&
> !HAS_ROWS is simple and it is good to be it exposed IMO...

Fine by me. The line that uses the macro in a68_lower_malloc is getting pretty long.
But that's a different discussion. :P

Thanks again for the review!
pietro


More information about the Algol68 mailing list