5.1. Example Programs
The repository contains small focused examples and larger demonstrations.
5.1.1 Language And Basics
| Example |
Shows |
examples/langdemo.dq |
broad language demo |
examples/langdemo_braces.dq |
brace-style syntax variant |
examples/basic/new_delete.dq |
manual allocation helpers |
examples/objects/dq_objects.dq |
objects, constructors, methods |
examples/objects/inheritance.dq |
object inheritance |
| Example |
Shows |
examples/string/embstrs.dq |
Embedded Strings |
examples/string/txtfmt.dq |
Format, AddFmt, stdout formatting |
5.1.3 Files
| Example |
Shows |
stdpkg/file/examples/fileiotest.dq |
file IO, directory helpers |
5.1.4 Time
See the time package documentation
for clock selection, formatting tokens, and sleep behavior.
| Example |
Shows |
stdpkg/time/examples/elapsed.dq |
measuring a duration with a monotonic clock |
stdpkg/time/examples/formatting.dq |
local and UTC timestamps, milliseconds and microseconds |
stdpkg/time/examples/periodic.dq |
periodic work using absolute deadlines |
5.1.5 Shell Commands
See the shell package documentation
for process execution, output capture, and background command lifetimes.
These examples support Linux and Windows.
| Example |
Shows |
stdpkg/shell/examples/capture.dq |
stdout/stderr capture, argument arrays, and exit-code handling |
stdpkg/shell/examples/input.dq |
supplying stdin and closing it with EOF |
stdpkg/shell/examples/background.dq |
background execution, timeouts, and cleanup |
stdpkg/shell/examples/environment.dq |
reading, setting, and inheriting environment variables |
5.1.6 Networking
| Example |
Shows |
stdpkg/nanonet/examples/simplebin_server.dq |
simple socket server |
stdpkg/nanonet/examples/http_static_files.dq |
HTTP server, query parsing, static files |
5.1.7 Threads
See the threads package documentation
for the APIs and example commands.
| Example |
Shows |
stdpkg/threads/examples/thread_test.dq |
starting threads and polling completion |
stdpkg/threads/examples/wait_test.dq |
message-channel waits and timeout checks |
stdpkg/threads/examples/stress_test.dq |
channel correctness with multiple producers and consumers |
stdpkg/threads/examples/work_distribution.dq |
distributing CPU work through a bounded channel |
Run an example with:
dq-run examples/string/txtfmt.dq
Some examples, especially networking examples, may need a free local port and a
host platform with the required socket APIs.