Module 6 Control Flow
Complex Sentences
Module 6: Control Flow
Complex Sentences — Branching, Looping, and Chaining Logic
You've got the runtime (word order), the type system (measure words), memory management (particles), error handling, a loaded stdlib, and character composition. You can build statements. But your programs are still single-line scripts.
Real programs need control flow — if/else, loops, try/catch, sequential execution. Real Chinese works the same way. Complex sentences use paired connectors that work exactly like the control flow structures you already know. Two keywords, working in tandem, shaping the logic.
// Your Chinese project so far:
import { SVO, TopicComment } from "grammar/runtime"; // Module 1
import { MeasureWords } from "grammar/types"; // Module 2
import { Particles } from "grammar/memory"; // Module 3
import { Negation, Questions } from "grammar/errors"; // Module 4
import * as stdlib from "vocab/core"; // Module 5
// Now we need logic:
import { If, TryCatch, CauseEffect, And, Loop, EventListener, Chain }
from "grammar/control-flow"; // THIS MODULE
1. if (condition) { result } —
如果...就...
The most fundamental control flow structure in any language. A condition, and a branch. In Chinese, 如果 sets up the condition, and 就 fires the result. The comma between them is your opening brace.
// Structure:
如果 [condition],(subject) 就 [result]。
// Maps directly to:
if (condition) {
result;
}
| Chinese | Pinyin | Code | English |
|---|---|---|---|
| 如果下雨,我就不去了。 | if (raining) { cancel(go); } |
If it rains, I won't go. | |
| 如果你累了,就休息吧。 | if (you.tired) { rest(); } |
If you're tired, (then) rest. | |
| 如果你喜欢,就买吧。 | if (you.like(it)) { buy(it); } |
If you like it, buy it. | |
| 如果没问题,我们就开始。 | if (!problems) { start(); } |
If there's no problem, we'll start. | |
| 如果你有时间,就来找我。 | if (you.hasTime()) { findMe(); } |
If you have time, come find me. | |
| 如果太贵了,我就不买了。 | if (price > budget) { skip(); } |
If it's too expensive, I won't buy it. |
if and just writing condition && action.
Shorter. Still works.
2. try { expectation } catch { reality } —
虽然...但是...
You expect one outcome, but reality throws an exception. 虽然 sets up what you'd expect, and 但是 catches the twist. It's concession logic: "I acknowledge X, however Y."
// Structure:
虽然 [expectation/concession],但是 [actual result]。
// Maps to:
try {
// You'd expect this to lead somewhere...
expectation;
} catch (realityCheck) {
// ...but here's what actually holds.
actual_result;
}
| Chinese | Pinyin | Code | English |
|---|---|---|---|
| 虽然很累,但是很开心。 | try { tired } catch { happy } |
Although (I'm) tired, (I'm) happy. | |
| 虽然中文很难,但是很有意思。 | try { hard } catch { interesting } |
Although Chinese is hard, it's interesting. | |
| 虽然他很年轻,但是很能干。 | try { young } catch { capable } |
Although he's young, he's very capable. | |
| 虽然贵,但是质量好。 | try { expensive } catch { quality++ } |
Although it's expensive, the quality is good. | |
| 虽然我学了,但是还是没通过。 | try { study() } catch { fail() } |
Although I studied, I still didn't pass. | |
| 虽然我不认识他,但是听说过他。 | try { !know(him) } catch { heardOf(him) } |
Although I don't know him, I've heard of him. |
3. cause: X → result: Y —
因为...所以...
Pure causal logic. 因为 states the cause, 所以 states the effect. It's structured logging: every outcome has a traceable reason.
// Structure:
因为 [cause],所以 [effect]。
// Like a logger entry:
logger.info({ cause: "raining", effect: "stayed home" });
// Or an assertion:
// GIVEN cause → THEN effect
| Chinese | Pinyin | Code | English |
|---|---|---|---|
| 因为下雨了,所以我没去。 | { cause: rain, effect: !go } |
Because it rained, I didn't go. | |
| 因为我生病了,所以今天不上班。 | { cause: sick, effect: !work } |
Because I'm sick, I'm not going to work today. | |
| 因为他很努力,所以成绩很好。 | { cause: effort, effect: goodGrades } |
Because he works hard, his grades are good. | |
| 因为太晚了,所以我们打车了。 | { cause: late, effect: taxi() } |
Because it was too late, we took a taxi. | |
| 因为我喜欢编程,所以当了工程师。 | { cause: love(coding), effect: became(engineer) } |
Because I like programming, I became an engineer. |
<because>cause</because><therefore>effect</therefore>.
4. condition1 && condition2 —
不但...而且...
Both conditions are true, and the second one escalates.
不但 establishes the
first truth, and 而且
stacks a second one on top. Like the && operator —
both sides must be true, and the right side often carries more weight.
// Structure: 不但 [fact A],而且 [fact B (often stronger)]。 // Like &&: assert(factA && factB); // both true, B escalates // Or Array.every(): [factA, factB].every(Boolean); // all conditions hold
| Chinese | Pinyin | Code | English |
|---|---|---|---|
| 她不但聪明,而且很努力。 | smart && hardworking |
She's not only smart, but also hardworking. | |
| 这家餐厅不但便宜,而且很好吃。 | cheap && delicious |
This restaurant is not only cheap, but also delicious. | |
| 他不但会说中文,而且会说日语。 | speaks("zh") && speaks("ja") |
He not only speaks Chinese, but also Japanese. | |
| 这份工作不但有意思,而且工资高。 | interesting && highPay |
This job is not only interesting, but pays well too. | |
| 他不但来了,而且带了礼物。 | showed_up && brought(gifts) |
He not only came, but also brought gifts. |
&& short-circuit
evaluation: if the first condition is already impressive, the second should be even more so.
Saying "She's not only a Nobel laureate, but also she likes pizza" is technically
grammatical but logically deflating. Keep the escalation climbing.
5. while (more(X)) { more(Y) } —
越...越...
A recursive, escalating pattern. The more one thing increases, the more something else
increases too. It's a feedback loop — like a recursive function whose output amplifies
with each call, or a while loop where the condition and the body scale together.
// Structure:
越 [A] 越 [B]
// The more A, the more B.
// Like:
while (true) {
A++;
B++; // B scales with A
}
// Or a reactive pattern:
X.subscribe(value => Y.set(value * scale));
| Chinese | Pinyin | Code | English |
|---|---|---|---|
| 越学越有趣。 | study++ → interest++ |
The more you study, the more interesting it gets. | |
| 越吃越胖。 | eat++ → weight++ |
The more you eat, the fatter you get. | |
| 我越想越生气。 | think++ → anger++ |
The more I think about it, the angrier I get. | |
| 天气越来越冷。 | time++ → cold++ |
The weather is getting colder and colder. | |
| 她说得越来越快。 | time++ → speed++ |
She speaks faster and faster. |
for (;;) { cold++; }. No external driver —
the value just keeps climbing on its own.
6. on("event", callback) —
一...就...
An event listener. The instant something happens, the callback fires. 一 marks the trigger event, and 就 marks the immediate response. Zero delay between event and handler.
// Structure:
(subject) 一 [trigger event],就 [immediate reaction]。
// Maps to:
element.addEventListener("event", () => {
reaction(); // fires immediately
});
// Or:
emitter.on("trigger", callback);
| Chinese | Pinyin | Code | English |
|---|---|---|---|
| 我一到家就吃饭。 | on("arrive_home", eat) |
As soon as I get home, I eat. | |
| 他一看到她就笑了。 | on("see_her", smile) |
As soon as he sees her, he smiles. | |
| 她一躺下就睡着了。 | on("lie_down", sleep) |
She falls asleep as soon as she lies down. | |
| 闹钟一响,我就起床。 | alarm.on("ring", getUp) |
As soon as the alarm rings, I get up. | |
| 我一听就懂了。 | on("hear", understand) |
I understood as soon as I heard it. |
if (maybe), the other is on("definitely").
7. await step1(); await step2(); —
先...然后...
Sequential execution. Do this first, then do that. No branching, no conditions — just ordered steps. It's a Promise chain, an async/await sequence, a pipeline where each stage runs after the previous one completes.
// Structure:
先 [step 1],然后 [step 2]。
// Maps to:
await step1();
await step2();
// Or Promise chain:
step1()
.then(() => step2());
| Chinese | Pinyin | Code | English |
|---|---|---|---|
| 先吃饭,然后看电影。 | eat().then(watchMovie) |
First eat, then watch a movie. | |
| 先学习,然后玩。 | study().then(play) |
First study, then play. | |
| 先洗澡,然后睡觉。 | shower().then(sleep) |
First take a shower, then sleep. | |
| 我先做完工作,然后去找你。 | finishWork().then(findYou) |
I'll first finish work, then go find you. | |
| 先往左,然后往右,然后一直走。 | left().then(right).then(straight) |
First left, then right, then straight ahead. |
.then() calls.
You can also swap in 再
() for a slightly different flavor:
先吃饭,再走。
再 implies
"and then after that" — same sequential logic, slightly more casual.
8. Error Severity Levels: 但是 vs 可是 vs 不过
Chinese has multiple words for "but," and they differ in weight — like the difference between throwing a fatal error, logging a warning, or printing a debug message. They all signal contrast, but the severity varies.
// Error severity analogy:
throw new Error("..."); // 但是 — formal, strong contrast
console.warn("..."); // 可是 — informal, moderate contrast
console.log("btw..."); // 不过 — mild, "by the way though"
// All three mean "but." The weight is different.
| Word | Pinyin | Register | Severity | Use When |
|---|---|---|---|---|
| 但是 | Formal / written | throw Error |
Writing, presentations, making a strong point | |
| 可是 | Spoken / casual | console.warn |
Everyday speech, conversation with friends | |
| 不过 | Soft / gentle | console.log |
Adding a small caveat, softening a contrast |
See them in the same sentence frame to feel the difference:
| Connector | Example | Feeling |
|---|---|---|
| 但是 | 我想去,但是没有时间。 | Firm. Written. Final. |
| 可是 | 我想去,可是没有时间。 | Conversational. Maybe a bit disappointed. |
| 不过 | 我想去,不过没有时间。 | Soft. "I mean, it's fine, just..." |
Control Flow Summary
/**
* Chinese Control Flow v1.0
*
* PAIRED CONNECTORS — your complex sentence toolkit:
*
* 1. 如果...就... if/then if (cond) { result }
* 2. 虽然...但是... although/but try { X } catch { Y }
* 3. 因为...所以... because/so { cause: X, effect: Y }
* 4. 不但...而且... not only/also A && B
* 5. 越...越... the more/more while(more) { scale++ }
* 6. 一...就... as soon as on("event", callback)
* 7. 先...然后... first/then step1().then(step2)
*
* "BUT" VARIANTS — error severity levels:
* 8. 但是 = throw Error (formal, strong)
* 可是 = console.warn (casual, moderate)
* 不过 = console.log (soft, gentle)
*
* KEY INSIGHT:
* - Chinese paired connectors work like MATCHED DELIMITERS
* - Both halves appear (unlike English which uses one or the other)
* - First keyword = setup, second keyword = payoff
* - Drop one in casual speech; keep both in writing
*
* NEXT MODULE: Module 7
* → You've got control flow. Time to build real programs.
*/
You now have the full control flow toolkit. These seven patterns handle the vast majority of complex sentences in everyday Mandarin. The paired-connector system is elegant and predictable — once you hear the first keyword, your brain can already predict the structure of the rest of the sentence. That's not memorization. That's pattern matching. And you're an engineer. Pattern matching is what you do.