aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Lidén Borell <samuel@kodafritt.se>2025-11-16 16:32:31 +0100
committerSamuel Lidén Borell <samuel@kodafritt.se>2025-11-16 16:35:23 +0100
commit4ca4db693711316a56deb7ba05608bfb01957bab (patch)
treeeccdafa5c44847c5292b48e940e8e7f959672c20
parent94cabfcf1aeef5f3583a326adc9b9e2306a0c435 (diff)
downloadslul-try2-main.tar.gz
slul-try2-main.zip
Basic interface definitions for the "core" module (work in progress)HEADmain
-rw-r--r--stdlib/core_wip.slul90
1 files changed, 90 insertions, 0 deletions
diff --git a/stdlib/core_wip.slul b/stdlib/core_wip.slul
new file mode 100644
index 0000000..e899578
--- /dev/null
+++ b/stdlib/core_wip.slul
@@ -0,0 +1,90 @@
+#
+# Interface definitions for the core runtime library (work in progress!)
+#
+# Copyright © 2025 Samuel Lidén Borell <samuel@kodafritt.se>
+#
+# SPDX-License-Identifier: EUPL-1.2+ OR LGPL-2.1-or-later
+#
+
+
+# XXX should there be different kinds of classes for service types and givemes?
+
+# XXX this structure makes nested (normal) classes impossible.
+# alternatives to normal nesting of classes:
+# - `nested class NC`
+# - `nested NC`
+# - `class NC = int x, bool b`
+# - different behavior in class-files
+# - `tuple NC = int x, bool b`
+# - `local class NC` (i.e. don't allow nested classes to be visible
+# to other files)
+# - inline tuples
+# - but it might lead to lots of repetition
+# - and then they cannot have methods
+# - unless you allow `func (int,bool).somefunc`
+
+# XXX this creates a difference between func and class
+# - no `end` for `class`
+# - but `end` required for `func`
+
+# XXX what if this file gets really large?
+# - add a way to split it?
+# - add a way to split modules? (better?)
+# - make it more compact? is that a good idea? (documentation comments etc.)
+# XXX api hashes (manual or automatic?)
+
+
+###########################################################################
+
+
+class CommandMain
+# Service interface for the main CLI command of an application
+
+
+###########################################################################
+
+
+class String
+# String of (possibly invalid!) UTF-8 bytes. Fully binary-safe, can contain
+# non-UTF-8 bytes as well as null bytes.
+
+
+###########################################################################
+
+
+class MessageReporter
+# A class that can be injected as a `giveme` to provide basic message
+# (error/warning/info) reporting
+#
+# TODO stdout vs stderr
+
+func begin_message
+# Starts a new message. Nothing is actually written until `report` is called.
+ String format
+ # TODO
+end
+
+func add_int
+# Adds a number as the next format parameter value.
+ int number
+end
+
+func report
+# Finishes a message, and outputs/reports it.
+end
+
+
+###########################################################################
+
+
+class Writer
+# Writes strings to some location. Can be injected as a `giveme` to get
+# access to `stdout` or `stderr`.
+
+func write_str
+# Writes a string to the output.
+ String s
+ # String to write. If the output supports binary, then it may contain
+ # binary (and invalid UTF-8). Otherwise, it should be valid UTF-8.
+ # (Encoding errors could perhaps be handled like I/O errors?)
+end