lout-users
[Top][All Lists]
Advanced

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

Re: Changing parameters midstream.


From: Valeriy E. Ushakov
Subject: Re: Changing parameters midstream.
Date: Sun, 23 Nov 1997 02:54:18 +0300

On Sat, Nov 22, 1997 at 07:52:57PM +0100, James A. Brister wrote:

> I tried this:
> 
>       @RawWideTaggedList labelwidth { 2c } 
>       ....
>       @EndList
> 
> but get complaints about double use of labelwidth (as RWTL is a macro that
> already uses it).

Use @RawTaggedList macro that doesn't specify a lablewidth (thus
@RawList defaults to @ListLabelWidth) and supply the labelwidth you
need.

    @RawTaggedList labelwidth { 2c } 
    ....
    @EndList


>                   The next, less desirable solution seemd to be to create
> my own macros similarly to RWTL (or just use the expansion directly), but
> it needs a symbol @TagPlace that isn't exported.

You can use "extend" clause to get to all the names visible in the
body of some symbol.  This is in expert's guide, section on nested
definitions (page 17).


>          and more generally, how can a value like @WideIndent be changed in
> the middle of a file (and can I restore its original value by a scoping
> mechanism). The user & expert guides don't talk a whole lot about the
> programming model...

Well, as Lout is programmed in a functional language things seems a
bit odd when one starts to program Lout.  It's important to keep in
mind that Lout properly implements lexical scoping and closures.
There's no direct analog of lisp LET form, but you have
export/import/@Open/@Use instead.  And named parameters with default
values allow you to easily glue scopes together: one syntactic sugar
trick is to import `x' and create another, exported, `x' that defaults
to imported `x'.  Look at ubiquitous examples (in particular,
@InitialFont &co are passed around in that way) in Lout standard
files:

    import @YYY  # import @ZZZ from @YYY
    export @ZZZ  # export our own @ZZZ 
    def @XXX
      named @ZZZ { @ZZZ } # our @ZZZ defaults to @YYY's @ZZZ
    ...

Named parameters can have their own parameters thus you can pass
functions as arguments (formatting list labels is one example).  In
principle, Lout implements complete lambda, but with somewhat unusual
syntax.  But it's a formatter after all, design goals was different.

I attach a simple complete example that should give some idea on how
to use scoping.

Hope it helps.

PS: Just remember to keep the right argument to @Open short (don't try
    to put a meg of stuff there) as Lout will read it in all at once.
    It's an unfortunate implementation restriction.  Changing @Use
    semantic from `to the end of input' to `to the end of scope' would
    help, but Jeff says it's hard to implement.  He knows better.

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

Attachment: foobar.lt
Description: Lout scoping rules example.


reply via email to

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