2.9 Headlines

Prev Up Next Page 12 of 800 Search internet

As mentioned, the lgs source of the combinations page starts thus:

     1  "";;0143BAB3BC67212340C9406BDB560819F3DCD4E859FC96F7B1C2B2BB0806
     2  ""P combinations

The first line starts with a ""; escape sequence so it is a comment. However, the lgc compiler assigns a special meaning to the first line if the four first characters of the source file are "";;

Whenever the lgc compiler translates a source file, it generates a vector which includes a timestamp and then computes a references which also includes the timestamp. The timestamp indicates the time at which the lgc compiler was invoked. Thus, if the same source file is translated twice, the result of the two compilations will be different due to differences in the timestamp.

In some situations it is nice to be able to recompile a source file several times with identical results. In such situations, the author of the source file should add a headline containing nothing but "";;, i.e. those four characters on a line by themselves as first line of the file.

When the lgc compiler sees that the source file starts with "";; it translates the file as usual and then writes the reference of the page back to the source file. The reference is expressed in mixed endian hexadecimal (bytes in network order, each byte as two hex digits with the most significant digit first).

Next time the lgc compiler translates the file, it sees that the source file starts with "";; followed by a reference. In that case the compiler extracts the timestamp of the previous compilation from the reference, translates the page, and compares the resulting reference with the reference of the headline. If the two references are identical then the lgc compiler decides that the source file has not changed and uses the reference. If the reference has changed, the lgc compiler decides that the source file has been changed after the headline was written back. In that case the compiler discards the timestamp of the previous compilation and uses the timestamp of the current invocation instead. This leads to a new reference which the compiler writes back to the headline of the source file.

Using headlines is convenient for source files which are going to be included in source distribution tar balls. But headlines can be a nuisance during development. As an example, I use the 'nedit' editor. If I have a source file open in nedit and the compiler writes back a headline then nedit asks if it should reload the file. If I click 'yes' then I get the new headline but loose the undo history. And the undo history is typically much more valuable to me than the headline.

Prev Up Next Page 12 of 800 Search logiweb.eu

Copyright © 2010 Klaus Grue, GRD-2010-01-05