public modes - a question
Jose E. Marchesi
jemarch@gnu.org
Thu Aug 27 18:26:01 GMT 2026
> Hi Chris.
>
>> Good morning everyone,
>>
>> I was reviewing the declaration for mode File today to see if any of
>> its fields are meant to be accessible outside the module. It seems
>> not, at least according to the RR p. 146 and van Vliet II p. 35.
>>
>> I wonder if it would be possible to enforce this "opacity" using a
>> pragmat, something along the lines of
>>
>> mode File = #[ opaque ]#
>> struct(ref Book book,
>> union(FlexText, Text) text,
>> Channel chan,
>> ref Format format,
>> ref int forp,
>> ref bool read_mood,
>> write_mood,
>> char_mood,
>> bin_mood,
>> opened,
>> ref Pos cpos { current position },
>> string term { string terminator },
>> Conv conv { character conversion key },
>> proc(ref File)bool logical_file_mended,
>> physical_file_mended,
>> page_mended,
>> line_mended,
>> format_mended,
>> value error mended,
>> proc(ref File,ref char)bool char_error_mended);
>>
>> The idea being that if mode File were pub(lished) in a module, the
>> names of its fields would NOT be published, so that users of that
>> module could not then:
>>
>> FIle foo;
>> {...}
>> Channel c = chan OF foo;
>
> This is a very interesting idea.
>
> Wouldn't the pragmat apply to fields rather than to the struct mode?
>
> Of course the pragmat should read #[ aleph ]#, because conceptually
> speaking the identifiers of the fields are preceded with an infinite
> number of i's and therefore un-typable, or so the lore tells ;)
FWIW I just added a TODO for this in the wiki.
More information about the Algol68
mailing list