[ previous ] [ contents ] [ next ]

About arfg

Description

arfg is a simple meta-language, combining various filters to produce its output. In a typical application, every input file filename.arfg is sandwiched between .arfg-pre and .arfg-post, fed to an arbitrary re-writing filter .arfg-rewrite, the m4 macro processor, a diversion filter, an embedded Perl interpreter, and an optional post-processing filter; the result is then written to filename. After completion of this procedure for all filenames, an external command may also be called.

For maximum flexibility, it is advisable to repeat calling arfg on a set of filenames until the files no longer change; with this it is possible to write self-configuring software and to provide for non-linear flow of information through the code base.

Simple as it may be, arfg is an extremely flexible and powerful tool, providing the programmer with the combined power of two programming languages, viz. m4 and Perl, designed to operate on very different levels of abstraction. Judicious use of divert, with a big diversion never included in the output, allows to code in a style not unlike literate programming preserving most of the advantages associated with this approach.

Take note of possible security issues; in short, arfg favors power over security. Also, due to the nature of the filters involved, arfg is probably completely useless for producing output heavily dependent on indentation levels, e. g. Occam programs or Haskell code with minimal parenthesization. For such languages, Norman Ramsey's noweb, or at least some of its filters, might be of interest.

Author and licence

arfg was written by Albert REINER. It is free software, released under the terms and conditions of the GNU General Public License.

The name of the game

Originally, arfg was named fml, for Fortran 90 meta-language; this, however, had to be changed as there already was a mailing list managing software of that name. arfg was then chosen as an acronym for ar's Fortran 90 generator, which has since turned out to be a misnomer as arfg's link to Fortran is only historical.

Motivation and history

When working on a theory that has to be implemented numerically, it is often necessary to be able to switch formulations of parts of the problems with a minimum of hassle. If, however, the conceptual separation of the problem according to the notions inherent in the theory itself cannot be mapped directly to the structures of the programming language chosen, a meta-language may be used to bridge this gap. Similar considerations apply when programming, e. g., in a commercial setting, having to deal with ever-changing or incomplete specifications on the customer's side, or when having to produce inconvenient output formats. In short, meta-languages increase flexibility by allowing high-level programming without having to resign on the advantages of the lower-level target language.

In one such situation, working on a Fortran 90 program combining ever changing approximations the manifestations of which were spread out through all of the code, arfg's author had to face a proliferation of mutually incompatible Fortran 90 MODULEs. In order to overcome the severe problems brought about by this and to reduce the administrative overhead he decided to slightly expand the used programming infrastructure's expressive power by adding some pre-processing. First, he just used eperl; soon, however, the necessity to combine it with other tools became apparent. Inspired by wml's pipelined structure, arfg was written as a Perl script assembling the necessary backends in a command line to be called via system(), with additional features being added as the need arose.

On a historical note it may be interesting to note that arfg, nowadays typically doing most of the processing in the m4 step, was first written to overcome some of the limitations of Fortran 90; m4 itself, on the other hand, also has a strong link to an earlier version of Fortran: In the History section of the GNU m4 manual we find:

Originally, `m4' was the engine for Rational FORTRAN preprocessor, that is, the `ratfor' equivalent of `cpp'.

Somehow Fortran seems to create a need for these code generation tools.

[ previous ] [ contents ] [ next ]


Copyright © 2001 by Albert REINER. All rights reserved.

URL: http://purl.oclc.org/NET/arfg/current/about.html

URL: http://purl.oclc.org/NET/arfg/2.9b/about.html

2001-10-08 19:13:57