lout-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Scoping (Was: Little PDF hack)


From: Valeriy E. Ushakov
Subject: Scoping (Was: Little PDF hack)
Date: Fri, 3 Apr 1998 16:58:26 +0400

On Sun, Mar 29, 1998 at 12:36:45AM +0100, Michael Piotrowski wrote:

> With LaTeX (which I know better), if I want to customize, say, the
> report document class, I make a new class file which first loads the
> original class, inheriting everything from it.  I then go on
> redefining just those things I need to change.  But with Lout it
> seems to me that it's common practice to make a copy of the entire
> original file and change it.  That right?

TeX is a macro language.  So you can redefine macros to your heart's
content almost anywhere in the document.  Suppose you have a macro
\foo and a macro \bar that makes use of \foo.  Suppose you redefined
\foo.  Then from the point of redefinition all macros will use the
redefined version of \foo since once, say, \bar is expanded, you have
no way to tell if the \foo was mentioned directly or it's a \foo that
resulted from the expansion of \bar.  More over, macro languages
usually *heavily* relies on this sort of behavior.  This is a kind of
dynamic scoping.

Lout, on the other hand, is programmed in a statically scoped
functional language.  This means that the meaning of @Foo in @Bar is
determined statically, or lexically.  To affect the @Foo in @Bar you
have to affect the @Foo the @Bar is closed over.  Check my message of
Nov 23 re changing parameters midstream.  It has an attachment with
some examples of how scoping and "import" interact.

I have attached another example that demonstrates how "extend" and
redefinitions work together.  In particular note, how @Bar is NOT
affected by redefinition of @Foo.

Important points are:

  * Lout is statically scoped and has proper closures
  * Lout has no assignable variables
  * Redefinition introduces *new* symbol

So if you want to change something and affect another symbol that is
closed over this something, then this something must be a parameter to
some symbol.

PS: Also note, that Lout has specialized form of dynamic scoping.  The
style information (@Font, @Break, @YUnit &c) is inherited through the
point of appearance.  Galleys are a lot of fun :-).

Hope it helps.

SY, Uwe
-- 
address@hidden                         |       Zu Grunde kommen
http://www.ptc.spbu.ru/~uwe/            |       Ist zu Grunde gehen

Attachment: try.lt
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]