6.6.4 Rendering

Prev Up Next Page 82 of 800 Search internet

You may change the rendering of the append function, if you like:

   ""P append
   ""R base
   ""D 17
   " ++ "
   page ( ""N , ""C )
   title "Append"
   bib "@MISC{dummy}"
   main text "
   \item "[[ eager define x ++ y as
             if x atom then y else x head :: x tail ++ y end define ]]"
   \item "[[ etst << 1 ,, 2 >> ++ << 3 >> ; << 1 ,, 2 ,, 3 >> end test ]]"
   appendix "
   \item "[[ tex show define x ++ y as x,"
   \mathrel{\makebox[0mm][l]{+}\,+}",y end define ]]"
   end page

The tex show definition in line 5 and 4 from the bottom tells how to render the append construct: It is done by appending the rendering of x, a particular string, and the rendering of y. Rendering of x ++ y yields x ++ y.

Care must be taken to get newline characters right in the rendering. If TeX sees a blank line in math mode it thinks something has gone wrong. So you cannot include too many newlines. And if you include no newlines you may get too long lines.

By convention, start all strings in the rendering by a newline unless you have very good reasons for not doing so. Do not end strings in a rendering with a newline unless you have very good reasons for doing so.

The lgc compiler recognizes two ways of rendering constructs: show and use rendering. The use rendering is used almost everywhere, but show rendering is used e.g. in the left hand side of definitions. In most cases, the use and show rendering are identical. Here are the typical cases:

Define neither show nor use rendering
Use this if you are happy with the default rendering which is based on the name of the construct.
Define a show but not a use rendering
Use this if you want something more fancy than the default rendering but the construct has to look the same both when it occurs on the left and on the right hand side of definitions. When no use rendering is given, the use rendering defaults to the show rendering.
Define a use but not a show rendering
Use this for special effects. As an example, the newline x construct inserts a \newline when used but is rendered as show newline x end show when shown. When no show rendering is given, the show rendering defaults to default rendering.
Define both a use and a show rendering
This is a rare case, but if you like, you can let a construct have one user defined rendering on the left hand side and a another user defined rendering on the right hand side of definitions. As an example, the meter long construct page ( x , y ) title t bib b main text m appendix a end page has show rendering show page ( x , y ) title t bib b main text m appendix a end page end show to save space.

The base page defines the newline construct above thus:

\item "[[ tex use define newline x as "
\newline "[ x ]"". end define ]]"

Prev Up Next Page 82 of 800 Search logiweb.eu

Copyright © 2010 Klaus Grue, GRD-2010-01-05