Modula-3 Counter and Theme Toggle - Modula3 Typing CST Test
Loading…
Modula-3 Counter and Theme Toggle — Modula3 Code
Demonstrates a simple counter with theme toggling using Modula-3 variables, procedures, and safe I/O.
MODULE CounterTheme;
IMPORT IO;
VAR
count: INTEGER := 0;
isDark: BOOLEAN := FALSE;
PROCEDURE updateUI():=BEGIN
IO.Put("Counter: "); IO.PutInt(count, 0); IO.PutLn();
IF isDark THEN
IO.PutLn("Theme: Dark")
ELSE
IO.PutLn("Theme: Light")
END;
END updateUI;
PROCEDURE increment():=BEGIN
count := count + 1;
updateUI();
END increment;
PROCEDURE decrement():=BEGIN
count := count - 1;
updateUI();
END decrement;
PROCEDURE reset():=BEGIN
count := 0;
updateUI();
END reset;
PROCEDURE toggleTheme():=BEGIN
isDark := NOT isDark;
updateUI();
END toggleTheme;
BEGIN
updateUI();
increment();
increment();
toggleTheme();
decrement();
reset();
END CounterTheme.Modula3 Language Guide
Modula-3 is a high-level, statically typed programming language designed for safe systems programming, modularity, and object-oriented programming. It emphasizes simplicity, safety, and readability while providing features suitable for building large, robust software systems.
Primary Use Cases
- ▸Safe systems programming
- ▸Concurrent applications
- ▸Compiler development
- ▸Networked and distributed systems
- ▸Educational projects on modular programming
Notable Features
- ▸Strong static typing with safety guarantees
- ▸Module system for large-scale software organization
- ▸Garbage collection for memory safety
- ▸Exception handling and concurrency primitives
- ▸Support for objects, generics, and interfaces
Origin & Creator
Modula-3 was developed in the late 1980s by the DEC Systems Research Center and Olivetti Research Center, building on ideas from Modula-2 and Pascal, with contributions from several academic and industry researchers.
Industrial Note
Modula-3 is used primarily in academic research, legacy systems, and projects requiring safe and concurrent programming in a modular architecture.