lout-users
[Top][All Lists]
Advanced

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

Re: Using defs/macros in @Cell definitions


From: Valeriy E. Ushakov
Subject: Re: Using defs/macros in @Cell definitions
Date: Mon, 5 Feb 2001 02:10:14 +0300
User-agent: Mutt/1.3.3i

On Mon, Feb 05, 2001 at 00:04:29 +0300, Milan Zamazal wrote:

> What I want is something like:
> 
>   macro @specialcell { @Cell width { 1p } }
>   ...
>   @Row format { ... | @specialcell C | ... }
> 
> Lout complains about an unknown symbol @Cell -- I don't know what to
> import to avoid this.

Lout has a very peculiar and potentially very confusing syntax for
what what you would call lambda in other functional langauges.

Consider this definition:

    def @Foo
      named say
        named A { 111 }
        named B { 222 }
      { A }
    { say }

Here named parameter "say" is really a function that takes its own
named parameters.  The question then is how to supply the value for
"say" as Lout doesn't have an anonymous functions syntax (i.e. lambda).
Let's use the term "funarg" (for "functional argument") to save us
from extra verbiage.  Thus "say" is a funarg of "@Foo" and "A" and "B"
are funarg's (own) parameters.

The Lout solution is that when you supply the value for a funarg, the
scope of funarg's body is in effect.

    @Foo                # 111   default
    @Foo say { A }      # 111   A from funarg's scope
    @Foo say { B }      # 222   B from funarg's scope
    @Foo say { C }      # C     unbound

To put it simply, when you supply a value for funarg, you have to know
the names of funarg's own parameters.

Thus @Foo say { B } evaluates to 222, as B is bound in the body of the
funarg, but @Foo say { C } evaluates to C, since C was not bound in
the funarg's body.

The reason for this digression into scoping rules is simple, @Cell is
just such a name, as in an outline the @Row looks like this:

    def @Row
      named format
        named @Cell {}
      {}
    {}

The problem is that you can not import or extend the scope of funarg's
body.  Jeff might give more gory details...

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


reply via email to

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