1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
Where and how should a program start?
=====================================
Types of programs
-----------------
There are different types of programs:
* Command-line applications:
- CLI arguments
- Environment variables
- stdin, stdout, stderr
* "Computer" GUI applications:
- May or may not have CLI
* Phone apps:
- No CLI:
- Can be stopped at any time
- Can be started due to different events. No single entry point.
* Server-side rendered web apps:
- May or may not have a session
(can have per-session or per-request state)
- No CLI
- Multiple events: New session, new request, loading a page,
events on a page (e.g. clicking a button)
* Client-side web apps:
- Needs to communicate with the server via some API
- No CLI
- Multple events: Load, user events, async API responses
* Servers
- Might run from inetd or systemd or as a Windows service or
something else.
- Multiple events: Start, stop, incoming request/data,
maybe even "readiness to send data" as an event.
Desirable properties
--------------------
* Intuitive to create an app
* Don't hard-code e.g. CLI into the language!
* Easy to add multiple entry points that get routed to
via some external framework.
* Hard to sneak in additional entry points.
- (Require `Entry` in the filename?)
- Have a separate file for entry points, e.g. `entry.index`?
- Could additionally require that entry points have
`entry` instead of `func`.
Multiple main/entry classes?
----------------------------
Without global variables, they only way for multiple main/entry classes to
access each other would be via the runtime. For example, via some kind of
singleton registry or service registry.
Also, with a "service registry" it would become possible to have multiple
instances of a single "main/entry class", e.g. for concurrent connections to
a service, concurrent sessions on a web page or similar.
How to specify and map entry points?
------------------------------------
See also `classes_interfaces_services.txt`
* Should map a type of entry point to a class
- Perhaps even a pattern/suffix of classes, e.g. `*Page`
(should be simple, perhaps max one `*`)
* Which methods are called on the class is dependent
on the type of entry point. It could search by
function name.
* The "caller side" that calls the entry points could use
the class and function names, e.g. for URLs or similar.
* But it should really be verified at compile-time, but also
not allow code execution at compile-time.
- Maybe there can be something in the interface of the
"entry point type" that describes this?
* Or should it go directly into `sources.index`, as an
additional tag/value after each filename?
Note that there are three types of entry points:
* Stateful initialization events:
- Implemented as constructors on classes.
- E.g. an event when a page or app is loaded
* Stateful events:
- Implemented as functions on classes.
- E.g. an event for a button click on a web page.
- Includes de-initialization (if applicable, and if reported).
* Stateless events:
- Implemented as a sequence of actions:
1. Call no-argument constructor (can be a default constructor)
2. Call the given entry function
- E.g. `main` in a CLI program.
Simple (but maybe limited?) solution: Same-named file
-----------------------------------------------------
If the project directory is called `example`, then maybe a file called
`Example.slul` should be searched for in the project directory?
(Is it possible to reliably determine the name of a directory on all
platforms? There could be symlinks etc. And what should happen in case
of a symlink?)
|