This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [WIP] Remove nested function in elf/dl-lookup.c? (Nested functions considered harmful?)


> Is it me or does reading do_lookup_x get very very complicated
> with the nested function check_match which has access to all
> sorts of function local variables?
>
> I'm always suspicious of nested functions like this as bad
> programming form since it complicates reading the function.

No, using a nested function like this vastly improves readability.
Having a function with arguments that are just copies of its callers
arguments is error-prone and tedious to read through.

> Is anyone opposed to rewriting this with a non-nested function
> that clearly shows which arguments are constant, and which are
> modified?

A good way to make that clear is to put the definition of the nested
function earlier in the scope, where only the things it uses have been
declared at the definition site.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]