|
From: | Jeffrey Kingston |
Subject: | Re: @Next magic |
Date: | Sat, 15 Dec 2018 20:19:42 +0000 |
Uwe,
Yes, I believe there are some heuristics in the Lout implementation that make @Next get evaluated early when possible. I forget why I did it but there would have been a good reason. Probably to do with reducing the number of runs needed to resolve all cross references.
Jeff From: Lout-users <lout-users-bounces+address@hidden> on behalf of Valery Ushakov <address@hidden>
Sent: Saturday, 15 December 2018 8:36:54 AM To: address@hidden Subject: @Next magic 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 } } } @Doc // @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. Jeff? -uwe |
[Prev in Thread] | Current Thread | [Next in Thread] |