[comp.text] A question about WEB and bibtex

anita@utastro.UUCP (02/13/87)

I got my version of TeX and LaTeX from another user of the same
brand of equipment in the form of already ported binaries (the machine
is an Integrated Solutions 68020).  It installed easily and runs
wonderfully.  My only problem was that the BiBTeX directory was munged
(not a directory at all but a file).  So, I just downloaded the appropriate
files from su-score to be able to bring up BiBTeX.  Among other files
is bibtex.web.  Well, in the document (bibtex.ins) it talks about using
appropriate changefiles but I know nothing about this.  In fact, I know nothing
about web and have no access to documentation on it.  I also am
unfamiliar with pascal (is that 3 strikes yet?).  Anyway, I ran
tangle on bibtex.web and it worked fine.  But, pc does not like
the .p file at all (this is a 4.2BSD system).  It has problems with
the lines "writeln(tty" and "write(tty".  It says tty is undefined.
Now what do I do?  What should be put where tty is?  What should a
changefile look like?  How do I get BiBTeX running or is it hopeless?

Please e-mail me responses as this is probably not of interest to others.

Thanks in advance.
 Anita Cochran  uucp:  {noao, ut-sally, ut-ngp}!utastro!anita
                arpa:  anita@astro.as.utexas.edu  
                snail: Astronomy Dept., The Univ. of Texas, Austin, TX, 78712
                at&t:  (512) 471-1471
-- 
 Anita Cochran  uucp:  {noao, ut-sally, ut-ngp}!utastro!anita
                arpa:  anita@astro.as.utexas.edu  
                snail: Astronomy Dept., The Univ. of Texas, Austin, TX, 78712
                at&t:  (512) 471-1471

ken@rochester.UUCP (02/13/87)

|unfamiliar with pascal (is that 3 strikes yet?).  Anyway, I ran
|tangle on bibtex.web and it worked fine.  But, pc does not like
|the .p file at all (this is a 4.2BSD system).  It has problems with
|the lines "writeln(tty" and "write(tty".  It says tty is undefined.
|Now what do I do?  What should be put where tty is?  What should a
|changefile look like?  How do I get BiBTeX running or is it hopeless?
|
|Please e-mail me responses as this is probably not of interest to others.

I think this is of interest to many people. This question comes up all
the time: where can I get free TeX or TeX software? Rest assured, TeX
is free, one can ftp stuff from score.stanford.edu. I think they would
be happier if one did it outside working hours, though. (C-TeX is also
here.)

Problem is, TeX and TeX software are mostly in Pascal and Pascal needs
help to cope with OS dependencies. Changefiles are basically patch
files generate slightly different Pascal outputs from the WEB file.
Sometimes, auxiliary routines written in other languages may be needed.
Thus one may find it more frustrating to work out what the changes
for ones local system are than to just get the machine/os specific
distribution, where someone has already done the grunge work. Look in a
recent issue of Tugboat for the site coordinators. TeXHax-request@score.
stanford.edu is the place to get on the TeXHaX mailing list where you
will get Q and A from other users.

So the specific answer to your question is: find a friendly 4.2 site
with the BibTeX files.

I'm just glad TeX isn't in SAIL anymore.

	Ken

amit@umn-cs.UUCP (02/14/87)

I never understood why each WEB program has its own .change file.
Since change files compensate for deficiencies of particular Pascal
compilers (relative to the one DEK worked with), one would imagine 
that there should be one change file per COMPILER, not per PROGRAM.

Would anyone care to explain this to me?

Neta Amit  (amit@umn-cs.arpa)
U of M CSci

ken@rochester.UUCP (02/15/87)

|I never understood why each WEB program has its own .change file.
|Since change files compensate for deficiencies of particular Pascal
|compilers (relative to the one DEK worked with), one would imagine 
|that there should be one change file per COMPILER, not per PROGRAM.

Tangle is the preprocessor that takes WEB files and generates Pascal.
Weave is the preprocessor that takes WEB files and generates TeX
documentation.

Think of tangle as Ratfor for Pascal.  Thus, think of WEB as an
enhanced Pascal language.  A change file can be optionally fed to
tangle to customize the WEB program for the environment.

So, to oversimplify, every program with extension .web will need .ch
files accompanying.

	Ken

ken@rochester.UUCP (02/16/87)

OK, Amit said my exposition wasn't clear enough. So did a friend here.

The assumption in the base posting is that one can compensate for each
compiler's deficiencies is that tangle can patch all instances of
features like OTHERWISE, etc, with one change file per compiler.
Let's call such change files compiler patch files (CPFs).

Unfortunately tangle isn't that smart. Change files are more like input
to Larry Wall's patch program, e.g. change line 100 to this.  If CPFs
were implemented, tangle (or some auxiliary program) would have to
parse tokens instead of just looking at line numbers.

Another problem CPFs can't handle is external routines.  In
dvidoc for example, random file positioning is used. Pascal-X may have
extensions for this, so all the patch has to do is make the changes
inline. Pascal-Y may have to call a C routine, and munge a couple of
parameters before calling. One can't anticipate all possible
substitutions to put in CPFs when writing them, especially if
the application doesn't exist yet.

Finally, one might want to enhance a WEB program to use facilities
that exist on the target system, like reading command arguments.
The base program might not have any WEB code for this at all.
Change files are the place to put these things.

Think of change files as implementing an #ifdef mechanism for WEB.
As far as I know, nobody has succeeded in parameterizing BSD and SysV
differences and writing an automatic translator for C programs either.

	Ken

amit@umn-cs.UUCP (02/17/87)

ken@rochester reasons why WEB programs need their own .change files:
1. TANGLE isn't smart enough to handle tokens; it can only refer to line
   numbers for patching. This dictates a .change file per program.

2. Differences between systems (read: compilers) cannot be listed in advance.
   In general, only when one ports an application from System-X to System-Y,
   will one find out that her Pascal-Y cannot do foo. She'll *then* tailor
   a .change file for the application.

3. The opposite: she may find out that her Pascal-Y can do much better than
   the original Pascal-X, and decide to rewrite parts of the original WEB code.
----------------

Terminology: CPF-XY: Compiler-Patch-File, for the Pascal compiler on System-Y.
	     PP: Patch-Program: accepts Prog-X and CPF_Y, produces Prog-Y.

(1) is a fact -- TANGLE cannot handle tokens. But PP might. Imagine the
sequence Tangle-then-PP. PP will take CPF-Y and a tangled WEB (= Pascal-X)
application program, and produce an equivalent Pascal-Y application program.
Nothing prohibits CPF-Y from generating external C routines, and calling them
from the Pascal-Y application.  ***TANGLE can still accept .change files!***

(2) is generally true -- it would be virtually impossible to list differences
between two similar complex systems.  My conclusion, though, is that when a
discrepancy has been discovered, modify CPF-Y, not just for the application at
hand, but once and for all.

(3) to me is less important than the issue of portability. Nonetheless, it *is*
possible to improve WEB programs through .change files, as indicated in (1).
----------------

So far, this doesn't look too complex, perhaps even suitable for a serious
Compiler Construction class. However, for the documentation to conform to the
program, the CPF-Y mods need to be incorporated. And WEAVE-then-PT (Patch
Text) is much-much harder than TANGLE-then-PP. On the other hand, this is not
crucial for the execution.

Summary:
1. TANGLE Prog.web [ Prog.change ]  ==> Prog.pas-x
2. PP Prog.pas-x CPF-Y		    ==> Prog.pas-y
3. Write a Prog.change file, which should closely match the CPF-Y mods,
   but on a line-by-line basis. Note, though, that this is not crucial
   for the execution of the ported program.
4. WEAVE Prog.web Prog.change       ==> Prog.tex

Neta Amit (amit@umn-cs)
U of Minnesota CSci

ken@rochester.UUCP (02/18/87)

Yes, of course what you suggest is possible. I remember a Software
Practice and Experience paper on CONVERT, a program for automatic
conversion of language dialects. I once had to do an automatic
converter for COBOL (shudder) with sed scripts.  (It's always the last
5% that's hard - COBOL can have uninitialized variable and record
alignment problems too!)

Knuth has been criticized for picking Pascal for TeX. In retrospect his
choice is not as bad as it seems. There were no C compilers for the
DEC-20 then. Also Pascal has spread TeX to many operating systems. As
Pat Monardo has demonstrated, once the algorithm is right, mechanical
translation into a decent language like C is not a problem.

Tangle was only meant to relieve some of the shorcomings of standard
Pascal.  It won't bear too much stretching beyond its original
charter.

	Ken