[Top][All Lists]

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

@Next magic

From: Valery Ushakov
Subject: @Next magic
Date: Sat, 15 Dec 2018 00:36:54 +0300
User-agent: Mutt/1.10.1 (2018-07-13)

I've finally got time to look at the /OUT pdfmark question by Mark and
swap in some of the Lout knowledge I used to have.

I'm pretty sure I ran into this before, but I can't remember any
specifics and can't find anything in the docs.  It looks like @Next
has some magic eager evaluation rules associated with it.

The following is a minimized example:

# lout -a -p count.lt | uniq
@SysInclude { doc }

export num def @SomeNumberedThing named @Tag {} right num {}
export num def @SetCounter left @Tag right num {}

def @Kludge right x { @Next x }
def @Fixup  right x { x @Minus "1" }

def @Counter
  left tag
  @Fixup { @SetCounter&&tag @Open { num } }

@Text @Begin
@LP The count will be my @Counter.

// @SomeNumberedThing @Tag { my } 42
// my @SetCounter {
     # - uncomment one (or none) of the following lines
     @Next # explicit @Next works
     # @Kludge # anything else, it seems, doesn't
     # 1 @Plus
     { @SomeNumberedThing&&preceding @Open { num } }

@LLP The count was my @Counter.
@End @Text
# ----8<----

With @Next in there I get

          The count will be 42.
          The count was 42.

But if I use anything else (including nothing), I get ??? instead of
the numbers.

As an interesting variation defining @Counter with an indirection (the
universal CS answer to any problem):

  def @Indirection { @SomeNumberedThing&&preceding @Open { num } }
  def @Counter left tag {  @Fixup @Indirection }

fixes the second number, but not the first.

If I uncomment the @Plus line and set a breakpoing in z08.c in
Manifest() in the code for PLUS - it's never hit.

If all the lines are commented out, then there's always

  no @SomeNumberedThing precedes this @SomeNumberedThing&&preceding

for the first @Counter instance.

Lout standard libraries are suspiciously consistent in using

  @SomeThing&&tag @Open { @Next val }

which makes me suspect I miss some evaluation quirk here.



reply via email to

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