Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Trickle down

5 views
Skip to first unread message

Claudio Calvelli

unread,
Sep 23, 2023, 4:50:59 AM9/23/23
to
There is a new feature in CLC-INTERCAL. Inspired by a previous UK
government, no less.

There is a new structure on registers, the "trickle down". It asks that
after assigning a value to a register, that value trickles down to some
other registers.

To set up:

DO TRICKLE (register1) DOWN TO (register2) AFTER (expression)

This arranges for (register1) to trickle down to (register2) after
(expression) milliseconds. For convenience, (register2) can be specified
as a list, which is equivalent to repeat the statement once for each
register listed.

Consider the two lines:

DO TRICKLE .1 DOWN TO .2 AFTER #1000
DO .1 <- #42

Register .1 will now contain #42 as expected. The program then keeps
running and after 1 second (1000 milliseconds), it will assign #42 to .2
as well. If multiple values are assigned to .1 in sequence, the same
values are assigned to .2 in the same sequence, at the appropriate time.

For example, this reads out "I", then waits 2 seconds, then reads out
"II":

DO .1 <- #1
DO TRICKLE .2 DOWN TO .1 AFTER #1000
DO TRICKLE .3 DOWN TO .2 AFTER #1000
DO READ OUT #1
DO .3 <- #0
(1) PLEASE COME FROM .1
DO READ OUT #2
PLEASE GIVE UP

The COME FROM will obviously come from itself, because .1 contains #1.
However, 1 second after assigning #0 to .3 that value will trickle down
to .2, and after another second it will trickle down from .2 to .1, at
which point the COME FROM stops looping and the program reaches the
second READ OUT.

To stop trickling down, you need to tie up the values in a register. The
verb for this is TRUSS UP, which obviously has nothing to do with the
name of any real person or UK prime minister. After all, it's a verb, so
it cannot be a noun. The syntax is:

DO TRUSS (registers) UP

After running that, any pending trickling down will keep happening, but
new assignments will trigger more trickling down.

Another way to stop it is to ABSTAIN FROM TRICKLING DOWN. This does not
stop the "TRICKLE DOWN" statement executing, but it does stop the
assignments from triggering trickling down. It is currently not
possible to stop the statements executing by an ABSTAIN FROM gerund, but
they can be stopped with an ABSTAIN FROM label. This means that in:

DO ABSTAIN FROM TRICKLING DOWN
DO TRICKLE .1 DOWN TO .2 AFTER #1000
DO .1 <- #1
DO REINSTATE TRICKLING DOWN
DO .1 <- #2

The first assignment does not trigger any trickling down, but the second
one does. Because the TRICKLE DOWN statement has set up the structure,
but trickling down was disabled at the time of the first assignment, but
enabled at the time of the second one. This could be potentially
confusing but this is how it works.

As an aside, the mechanism which detects tight loops and replaces them
with a sleep has been extended to check for pending trickle downs: in
this case, the COME FROM will execute once, notice the tight loop and
the pending trickle down, and sleeps 1 second; then it executes a second
time, notices the tight loop and the other pending trickle down, so it
sleeps a second again, and then finally it stops executing. This can be
seen by looking at the program trace (I added a comment where it
sleeps):

$ sick trickle-down.i
$ ./trickle-down.io --trace
[1] @STS 0 4 0 20 0
01 01 40 01 | STO #1 SPO #1
[1] @STS 4 9 20 41 0
30 40 02 7F 03 E8 40 01 | TRD SPO #2 #1000 SPO #1
[1] @STS 13 9 61 41 0
30 40 03 7F 03 E8 40 02 | TRD SPO #3 #1000 SPO #2
[1] @STS 22 3 102 19 0
I
14 01 | ROU #1
[1] @STS 25 4 121 12 0
01 00 40 03 | STO #0 SPO #3
[1] @STS 29 3 133 28 32
[1] @LAB 1
16 | CFL
[1] @COMEFROM (1)
40 01 | SPO #1
(there is a 1 second delay here)
[1] @TRICKLED .2 <- #0
[1] @STS 29 3 133 28 32
[1] @LAB 1
16 | CFL
[1] @COMEFROM (1)
40 01 | SPO #1
(there is a 1 second delay here)
[1] @TRICKLED .1 <- #0
[1] @STS 29 3 133 28 32
[1] @LAB 1
16 | CFL
[1] @COMEFROM (1)
40 01 | SPO #1
[1] @STS 32 3 161 19 0
II
14 02 | ROU #2
[1] @STS 35 1 180 16 32
12 | GUP

This will find its way in the 1.-94.-2.3 escape which I fear might
happen soon. In the meantime, it's in the git repo.

C

Claudio Calvelli

unread,
Sep 23, 2023, 5:04:26 AM9/23/23
to
Oh and I should add. The trickled down assignments are executed as
though an actual assignment had magically appeared in the program at the
time the trickle down happens.

This means that:

DO TRICKLE .1 DOWN TO .2 AFTER #1000
DO .1 <- #1
PLEASE IGNORE .2

If there is no REMEMBER .2 within a second, the trickled down assignment
won't happen because .2 is IGNOREd.

Also:

DO TRICKLE .1 DOWN TO .2 AFTER #1000
DO .1 <- #1
DO .3 <- .2/#3

After one second the value of the "constant" #3 will be changed to #1.
Because .2 is overloaded at the time of the trickled down assignment,
so what actually runs is:

DO #3 <- #1

C

0 new messages