Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

programming purely in CWEB

9 views
Skip to first unread message

Allan Adler

unread,
Sep 16, 2006, 2:57:29 AM9/16/06
to

As I mentioned in another posting, I recently started with someone else's
non-literate program and for practice am converting it to a literate
program using CWEB. I still have a lot of work to do with it but I have
so far managed to produce a CWEB file that runs through cweave and then
TeX, to produce a document that is helping me study the program in detail,
and also through ctangle and then gcc, to produce an executable that
performs correctly. This isn't the first time I've tried something like
this, but it is the first time I've gotten this far and felt that I will
eventually succeed with it.

What I'm contemplating now is writing another C program of my own but,
instead of writing it directly in C, writing the whole thing from
scratch in CWEB. I'm under the impression that this is the way one
is supposed to write literate programs with CWEB, instead of writing
the original C program all at once or in parts and then translating
into CWEB. I'll try it this way, following my nose, but I'd just like
to know from others who do things this way:
(1) how hard is it to get used to writing C programs directly in CWEB?
(2) can you describe the compositional process?
--
Ignorantly,
Allan Adler <a...@zurich.csail.mit.edu>
* Disclaimer: I am a guest and *not* a member of the MIT CSAIL. My actions and
* comments do not reflect in any way on MIT. Also, I am nowhere near Boston.

Torsten Bronger

unread,
Sep 16, 2006, 5:41:49 AM9/16/06
to
Hallöchen!

Allan Adler writes:

> [...]
>
> [...]


>
> (1) how hard is it to get used to writing C programs directly in
> CWEB?

I didn't find it much harder than writing directly, however, it
depends on your programming style. For example, I'm not able to
"plan" programs with pen and paper, I just program directly. In
this case, you cannot create all chunks and comments at once because
much reordering may become necessary.

I write portions of code that are still tamable in one go (some 1000
lines), and then add all the CWEB commands and comments to it.

> (2) can you describe the compositional process?

One thing that was an important realisation to me was that you
shouldn't make use of CWEB's nesting and reordering feature very
much. Eventually, I used in only to get the main() function at the
beginning of the document. Apart from this, it's good to keep the
code in its natural order, just as the compiler sees it, because
everyone is accustomed to this.

You may make exceptions for very interesing parts of functions that
you want to explain in detail; but keep such exceptions local and
limited.

Tschö,
Torsten.

--
Torsten Bronger, aquisgrana, europa vetus
ICQ 264-296-646
(See http://ime.webhop.org for Jabber, MSN, etc.)

0 new messages