why no ++?

Marcin 'Qrczak' Kowalczyk qrczak at knm.org.pl
Thu Aug 9 04:25:50 EDT 2001


9 Aug 2001 07:49:44 GMT, Marcin 'Qrczak' Kowalczyk <qrczak at knm.org.pl> pisze:

> - If an operation can be written as either returning a result
>   or storing it somewhere, it's generally better to return it.
>   I.e. queries should not be unnecessarily expressed as commands.
>   Separate gathering inputs, processing, and using outputs.

Maybe I'm biased by digging in a compiler, but I would also say:

Even invent an explicit representation of intermediate form of
the processed data. Don't try to do all stages at once. Partition
processing wrt. stages, not just wrt. kinds of data (as OO says).

It will be easier to add a rewriting stage in the middle, change
implementation of a stage, replace final processing to use the output
differently, replace initial processing to take inputs from a different
source, print intermediate data for debugging.

In the program I wrote for producing <http://qrczak.ids.net.pl/vi-001.gif>
I recently added an option to output TeX source (for a suitable
font) instead of rendering the bitmap myself. One of intermediate
representations was very suitable for translation to TeX commands.
I just plugged a different sequence of stages:
  - lexical analysis of input - as for bitmap rendering,
  - grouping consonants - as for bitmap rendering,
  - paragraph and page breaking - removed,
  - determining letter shapes, corner rounding, putting dots, adding
      serifs - as for bitmap rendering, except that Latin letters
      are not rendered but passed as text,
  - rendering graphical pieces on a bitmap - removed,
      outputting TeX commands instead.

OTOH I saw sources of two pieces of software which probably do too
many stages at once: SmallEiffel implementation (written in Eiffel)
and Doxygen (written in C++).

Python's generators should help with partitioning sequence processing,
so intermetiate representations don't need to be kept in memory in
the whole. With some luck very big data can be passed through many
stages in a little memory and the ability to stop at any point.

-- 
 __("<  Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/
 \__/
  ^^                      SYGNATURA ZASTĘPCZA
QRCZAK



More information about the Python-list mailing list