연결됨 다시 연결 중 다시 연결 초 연결 실패 연결 일시 중지 복구 실패
Sollang streams now work end to end in Stage2 and on the web · Cover image

Sollang streams now work end to end in Stage2 and on the web

Public posts

A Sollang development log covering lazy Stream<T>, EventStream<T>, Stage2 WASM, regression checks for the exact output of all 31 examples, and mobile playground improvements.

This time, I got Sollang streams working end to end.

The initial question was simple. Can a stream created like LINQ be stored in a variable and then processed with each? Can it be passed directly without first copying the result into memory? Can events such as mouse clicks or movements also be handled using the same combination method?

The answer to this task is Possible.

Stream<T> is a execution plan rather than a container

Even if Stream<T> is stored in a variable, the result array is not created immediately. The variable retains a delayed execution plan, and only when terminal operations like each, fold, and take are performed, the required value is pulled from upstream.

So even if 1 billion sensor values are declared, 1 billion are not stored in memory. In this example, only 54 are actually read to get 5 warnings, and then it stops. If the downstream take is filled within flatMap, the entire overlapping upstream is immediately canceled.

This structure is the same even at the library boundary. The stream function created by the user returns a execution plan, and the caller can consume it later with each.

EventStream<T> uses the same combination model too

Input values that arrive forward, such as mouse movement and clicks, have been separated into EventStream<T>. While the pull-based Stream<T> differs from the lifespan model, it maintains the combination feel of map/filter/take.

Native event streams explicitly handle bounded queues, overflow policies, and subscription cancellation and drops. The browser target silently ignores the absence of host callback lowering and issues a compilation error indicating that it is currently unavailable. This approach is much safer than making an unsupported feature appear to work successfully.

Stage2 compiles to the same actual code

This time, the longest‑lasting part was connecting everything accurately from the stream meaning that worked well in C# Stage1 to the self‑hosted Stage2 where it was written as .slg.

Preserved the range as a first-class source, and updated each/fold binding, the type of nested flatMap elements, state/scan, take/skip, stop cancellation, and raw string and when fallbacks. The web does not use any separate minification compiler or hardcoding results. Stage2 is built as wasm32 to reduce the editor’s code to LLVM- and executable WASM.

For example, this code now prints exactly three lines.

main {
    1..3 -> each {
        "Range item" -> println
    }
}

1..100 -> fold outputs 5050 instead of 1, and the user block example actually calls notify and yield.

The 31 examples now compare even the output.

In previous checks, there was a section that only checked whether the execution was complete or if the stdout wasn’t empty. So even if a line unrelated to the sample appeared, it could pass.

Now, a fixed expected stdout has been set for each of the 31 samples. Empty output, partial output, incorrect fold value, number of iterations per sample, branch conditions, raw strings, and early termination of the stream are all treated as failures.

Code that calls a non-existent function is no longer ignored either.

"Values flow from left to right." -> println2

This code causes a compilation error because println2 cannot be found.

On mobile, the code appears first.

I changed the layout so that the introduction text takes up more space on the mobile screen than in the editor. Now, the code workbench and execution results appear first, while the introduction text is placed at the very bottom of the page behind the footer. I verified the order using a 390×844 actual browser window.

Verification result

  • Total regression: 785/785
  • Windows Stage2: 7/7, fresh verification 93 seconds
  • Linux Stage2: 6/6, fresh verification 101 seconds
  • Windows/Linux Stage3: fixed point matching
  • Browser: 31 samples × 4 locales, accurate stdout output
  • GitHub Pages: Deployment successful
  • sollang.slogs.dev: DNS CNAME, TLS, HTTP 200 verification
  • Resignation P:\Utils\sollang: Matches latest package and SHA-256

The change has been reflected in main as a commit of 66f1982.

You can run it directly.

https://sollang.slogs.dev

With this implementation, Stream goes beyond grammar demos; it is designed to be executed only as needed, stored in variables, across library boundaries, and within the same validation network as Stage1, Stage2, native, and browsers.

0 Comments

Comments: 0

Sign in to leave a comment.

No comments yet. Write the first one.

The server connection was interrupted. Reconnect ×