Programming language scoping is missing the intersection

Thoughts on pipelines and programming language primitives for encapsulation

A thought has come to my mind, which I will share here for no particular reason. Since computing is mostly about making data flow from one point to another with some transformation in between, code is often designed as a pipeline with shared state between stages. Here is an explanatory diagram of the concept:

| A | -> | B | -> | C | -> ... -> | Z |
   |      | |      | |     | |     |
   '------' '------' '-----' '-----'
      ^        ^        ^       ^
      '--------'--------'-------'
                    |
               data-channel

However, now comes language scoping. It is not a pipeline, it has a recursive layout. Lets say I want to send a variable X from A to B. Then X must be in a scope that is shared between A and B. Hence we will have this partial scoping diagram:

{
    X

    { A }

    { B }
}

We will now add another variable Y that goes from B to C and think of a first possible solution to our pipeline problem:

{
    X

    { A }

    {
        Y

        { B }

        { C }
    }
}

With this approach A is not able to access Y but B and C can access X. We try again moving C out of the scope of X.

{ Y
    {
        X

        { A }

        { B }

    }

    { C }
}

With this approach, C is not able to access X but A can access Y.

Neither approach helps us achieve our desired pipeline. How could we fix this? Well, after not thinking too much (thus maybe an inappropriate solution), here is what I am thinking:

pipeline
    X

    -- Do A

chained
    forward X
follows
    Y

    -- Do B

chained
    forward Y
follows

    -- Do C

end pipeline;

Inside the chained sections, code would be able to access the previous scope and declare elements that will be kept for the next scope.

As of writing this ...

Been coding the whole day the initial stages of a RiscV VM in Ada and I am a bit tired. I think I will now take a break.

Izan, 09 Jun 2026, LLU blog