[m-users.] Bug in posix.readdir (fixed)
Julien Fischer
jfischer at opturion.com
Mon Oct 14 13:43:28 AEDT 2019
On Mon, 14 Oct 2019, Volker Wysk wrote:
> Am Montag, den 14.10.2019, 13:06 +1100 schrieb Zoltan Somogyi:
>>
>> On Mon, 14 Oct 2019 03:58:18 +0200, Volker Wysk <post at volker-wysk.de>
>> wrote:
>>> Not sure if I understand correctly, but wouldn't it just be one
>>> level
>>> of switching:
>>>
>>> readdir(Dir, Res, !IO),
>>> (
>>> Res = ok(yes(File)),
>>> ...
>>> ;
>>> Res = ok(no),
>>> ...
>>> ;
>>> Res = error(Err),
>>> ...
>>> )
>>
>> That is actually two levels of switching: first ok vs error, then
>> (in the ok case) yes vs no. The fact that you can flatten that out
>> in the surface syntax does not change the fact that the generated
>> code does two nested switches.
>
> Okay. But would that be a bad thing? (I'm just wondering.)
"Bad" may be too strong a word. IMO, the nested type is less desirable
because:
1. the two-level switch is more expensive. The flat version
just needs to switch on the primary tag.
2. "ok(no)" is less meaningful indication of end-of-file (end-of-stream)
than a purpose specific functor like eof.
3. As a I mentioned elsewhere, it's less consistent with how this
situation is treated by the stdlib etc.
Julien.
More information about the users
mailing list