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

Pietro Monteiro pietro@sociotechnical.xyz
Wed Jan 14 22:54:44 GMT 2026



On Wed, Jan 14, 2026, at 5:25 PM, Jose E. Marchesi wrote:
>> On Wed, Jan 14, 2026, at 4:06 PM, Jose E. Marchesi wrote:
>>>> It still feels weird to pass a MOID_T and a tree to
>>>> a68_lower_malloc. :P
>>>
>>> :)
>>>
>>> Just a little thing:
>>>
>>>> +#define LEAF_P(m) (!IS_REF (m) && !HAS_ROWS (m))
>>>
>>> I think it would be better to call that macro IS_LEAF.  It matches
>>> better with the current style.
>>>
>>> This looks very good!
>>> Does it work? :)
>>
>> All tests pass on x64_64 with and without "-m32" ;)
>>
>> I took another look at the the front end code and I think I'll add a is_leaf function that:
>>
>> If the mode is REF, FLEX or ROW: returns false. This is pretty much the current macro.
>>
>> And also if the mode is STRUCT or UNION: return false if any mode in
>> the PACK_T chain is not leaf, else true.
>> Return true otherwise.
>>
>> WDYT?
>
> Hmm, the HAS_ROWS takes "contained" modes into account, but yes, it
> doesn't take REFs into account.
>
> I think what you need is to add a has_rows field to struct MOID_T, plus
> accessor macro HAS_REFS.
>
> Then in a68-parser-modes.cc you can compute it for all modes, writing a
> function is_mode_has_refs to accompany the existing is_mode_has_rows.
>
> Then use leaf malloc if the mode !HAS_ROWS && !HAS_REFS.
>
> HAS_REFS will be useful for other purposes too...

I'm going to try doing that. I'll scream for help if I get stuck :P

pietro


More information about the Algol68 mailing list