Re: [scheme-reports-wg2] Threads and futures Per Bothner 01 Apr 2022 23:49 UTC

On 4/1/22 16:27, Ray Dillinger wrote:
> Coding the 'optimization' correctly though is problematic because
> you don't know what you don't know about the header and how it's going
> to interact with other header variables that have been set since the
> most recent time it was parsed.  It's easy if we assume that headers are
> idempotent.  But in conforming C/C++ they are not idempotent unless the
> contents make them so.

A "correctly-written" header file has the format:

/* comments and whitespace */
#ifndef GUARD
BODY
#endif
/*trailing comments and whitespace */

The first time you read the file, it is easy to verify that it matches
this format, and if so stash (EXPANDED_FILENAME, GUARD) in a hash table
On subsequent encounters of #include EXPANDED_FILENAME it is easy to
check GUARD: if it is defined, no need to open the file.
--
	--Per Bothner
xxxxxx@bothner.com   http://per.bothner.com/