[comp.lang.objective-c] C-Refine preprocessor really available

prechelt@i41s14.ira.uka.de (Lutz Prechelt) (05/29/91)

Some people had difficulties retrieving C-Refine (compressed file corrupt).
I hadn't and still don't know why they had but we have put a newly
compressed version of C-Refine into the archive and -- well, it seems
to be 5 bytes larger than the old one....

Please give me feedback if you still have problems uncompressing it.

So here we go again:

C-Refine is available for anonymous ftp now from
  iraun1.ira.uka.de [129.13.10.90]
  /pub/src/crefine.tar.Z
as
-rw-r--r--  1 ftpadm   XLINK       70403 May 28 17:27 crefine.tar.Z

It will soon (hmm, may take some weeks...) be posted
to comp.sources.unix also.

C-Refine is a preprocessor for programs written in C or C++ or a similar
language. It introduces an additional language construct called 'refinement'
which allows further decomposition with symbolic names inside functions.
This makes programs much easier to read and modify and is very comfortable
for programming.

Here is the tiny example program from the manual page,
so that you can grasp the idea:

 "This is a (very simple-minded) version
  of the Sieve of Eratosthenes. It should not be  thought
  that  I  believe  the  refinement technique to be espe-
  cially well suited to this problem, but  this  was  the
  smallest 'real' problem I could think of to demonstrate
  at least most of what  the  possibilities  of  C-Refine
  are. So here it is:
  /***** EXAMPLE : The Sieve of Eratosthenes *****/
          #define MAX        10000
          #define PRIME      0
          #define NON_PRIME  1

          static int sieve[MAX+1];

          int main ()
          {
            `initialize;
            `do sieve;
            `make output;
            return (0);

          `initialize:
             int actual;
             for (actual = 2; actual <= MAX; actual++)
               sieve[actual] = PRIME;

          `do sieve:
             int actual_prime = 1;
             for (;;) {
               `find next bigger prime;  /* perhaps leave 'do sieve here */
               `delete all multiples of actual_prime;
             }

          `find next bigger prime:
             actual_prime++;
             while (sieve[actual_prime] == NON_PRIME)
               if (actual_prime == MAX)
                 leave `do sieve;    /* leave two refinements at once */
               else
                 actual_prime++;
             /* now actual_prime is a prime (or we leave `sieve) */

          `delete all multiples of actual_prime:
             int actual = `first multiple of actual_prime;
             while (actual <= MAX) {
               sieve[actual] = NON_PRIME;
               actual += actual_prime;
             }

          `first multiple of actual_prime:
             2 * actual_prime

          `make output:
             int actual;  /* different from 'actual' above */
             printf ("The primes between 2 and %d are ", MAX);
             for (actual = 2; actual <= MAX; actual++)
               if (`actual is prime)
                 printf ("%d ", actual);

          `actual is prime:
             sieve[actual] == PRIME

          } /* end of main() */

          /***** End of example *****/"

The installed system consists of a single executable file (crefine) and one
Unix Manualpage (crefine.1). No further data files or libraries
except the standard C library are needed, so C-Refine is easily portable.


   Lutz


Lutz Prechelt   (++49/721/608-4317,  FAX: ++49/721/697760)
Institut fuer Programmstrukturen und Datenorganisation
Universitaet Karlsruhe;  D-7500 Karlsruhe 1;  Germany
prechelt@ira.uka.de  or  prechelt!ira.uka.de@relay.csnet