Re: [hackers] [PATCH sbase] libutil/recurse: Split into two functions

From: Richard Ipsum <richardipsum_AT_vx21.xyz>
Date: Wed, 24 Jun 2020 23:34:35 +0200

On Tue, Jun 23, 2020 at 11:26:27AM -0700, Michael Forney wrote:
> Thanks for testing this out, Richard.
>
> On 2020-06-23, Richard Ipsum <richardipsum_AT_vx21.xyz> wrote:
> > I don't feel qualified to criticise the overall design, but do we not still
> > need a way to specify whether traversal should be pre-order or post-order?
> > I figure this is what DIRFIRST was for right?
>
> The effective traversal order can be controlled by structuring your
> recursor function to call recursedir() at the beginning or end.
>
> DIRFIRST was only useful because a top-level directory was handled
> specially by recurse. Normally, recurse() does not "visit" its
> argument at all, only its children. For D/f, the call structure was
> something like this for DIRFIRST:
>
[snip]
>
> As you can see, the DIRFIRST flag is only used at the toplevel for
> bootstrapping. In other cases, it is ignored, since the function is
> just structured differently depending on whether it needs the children
> processed first or last:
>
> fn(D)
> do something with D
> recurse(D)
>
> or
>
> fn(D)
> recurse(D)
> do something with D

Makes sense, thanks for the explanation!

Thanks,
Richard
Received on Wed Jun 24 2020 - 23:34:35 CEST

This archive was generated by hypermail 2.3.0 : Thu Jun 25 2020 - 00:00:40 CEST