• R/O
  • SSH

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revision924a35e5b4bb827cf6150bfef8ef48906e1f7f6f (tree)
Time2023-01-14 06:56:08
AuthorAlbert Mietus < albert AT mietus DOT nl >
CommiterAlbert Mietus < albert AT mietus DOT nl >

Log Message

asis DRAFT

Change Summary

Incremental Difference

diff -r bb37490e83b0 -r 924a35e5b4bb CCastle/4.Blog/b.TheSieve.rst
--- a/CCastle/4.Blog/b.TheSieve.rst Thu Jan 12 20:15:33 2023 +0100
+++ b/CCastle/4.Blog/b.TheSieve.rst Fri Jan 13 22:56:08 2023 +0100
@@ -1,4 +1,4 @@
1-.. include:: /std/localtoc.irst
1+.. .. include:: /std/localtoc.irst
22
33 .. _Castle-TheSieve:
44
@@ -12,10 +12,10 @@
1212
1313
1414 To show some features of CCastle, I use *‘the sieve’*, short for the `Sieve of Eratosthenes
15- <https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes>`__. An old, well known, algorithm to find prime numbers. with
15+ <https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes>`__. An old, well known, algorithm to find prime numbers; with
1616 impliciet concurrency.
1717
18- With an almost trivial implementation, many “CC concepts” are shown. In only a handful of lines.
18+ With an almost trivial implementation, many “CC concepts” can be shown. In only a handful of lines....
1919
2020 The design
2121 **********
@@ -29,9 +29,10 @@
2929 =========================
3030
3131 CCastle use “components” [#not-package]_ as main decomposition. Each kind of component can be instantiated multiple
32-times; which often are also called *component*. One can also use the term *element*, to denote it is one (of possible)
33-many instantiated component-types. This is very ,like *“classes” vs “objects”* [#active-class]_.
32+times; sometimes called a *element*, or also just *component*. This is very like *“classes” and “objects”* in OO
33+[#active-class]_.
3434
35+Let’s introduce the those components
3536
3637 Generator
3738 ---------
@@ -39,21 +40,22 @@
3940 This component generates just numbers, which will be tested for prime (see below). As primes are always integer bigger
4041 then one; it output is the stream stream of numbers: 2,3,4, …
4142
42-Sieve (parameterised)
43----------------------
43+Sieve (on prime)
44+----------------
4445
45-We use a (growing) chain of sieve-elements. Each behavior is the same; except for the constant that it gets when
46-creating. That number is a prime; as will see below.
46+We use a (growing) chain of sieve-elements. Each one is the same; except for the sieving-constant --a already found
47+prime. That number is set when instantiating the element.
4748
48-Each Sieve tries to divide each incoming number to its own, already known prime-number. When the modulo isn’t zero, we
49-call it a *coprime* (relative to the already tested primes) and send downstream. When it can be divided, the number is
50-clearly not prime and ignored
49+
50+Each Sieve tries to divide each incoming number to its own, sieve-constant. When the modulo isn’t zero, we call it
51+a *coprime* (relative to the already tested primes) and send downstream. When it can be divided, the number is clearly
52+not prime and ignored
5153
5254 Finder
5355 ------
5456
5557 Each number that comes out of the chain of sieves is a prime (that is the algorithm; see Wikipedia for details). It is
56-collected by the finder. And for each found prime, an extra sieve (element) is created and added to the chain. This kind
58+collected by the finder. For each found prime, an extra sieve (element) is created and added to the chain. This kind
5759 of shifts the finder to the right (aka downstream)
5860
5961 In some implementations that is the responsibility of the finder (therefore sometimes calls “head”). In a variant, the
@@ -61,17 +63,31 @@
6163
6264 Communication
6365 =============
66+.. include:: ./sieve-protocols-sidebar.irst
67+
68+CCastle uses “protocols” to communicate between components. There are several kind of protocols; we use the ‘event’ kind
69+here. Two ports can be connected when both use the same protocol.
70+
71+Notice, that a *protocol* is not the same as an API in most language’s. A fundamenta concept of :ref:`CC`/CCastle is the
72+strict seperation between outside and inside
73+
74+
75+
76+
6477
6578 SimpleSieve
6679 -----------
6780
68-In the basic variant,we use an event-based protocol, that just hold one event (read: a message), that carries the
81+In the basic variant, we use an event-based protocol, that just hold one event (read: a message), that carries the
6982 integer to be tried.
7083
7184 StartSieve
7285 ----------
7386
74-XXXX
87+The StartSieve protocol signals to start sieving (so generating numbers), and when to stop. This “max” number is the
88+maximal number to be tried, and does not need to be a prime.
89+
90+Currently, the is no way to specify the number of primes to be found.
7591
7692 Main
7793 ****
diff -r bb37490e83b0 -r 924a35e5b4bb CCastle/4.Blog/sieve-design.irst
--- a/CCastle/4.Blog/sieve-design.irst Thu Jan 12 20:15:33 2023 +0100
+++ b/CCastle/4.Blog/sieve-design.irst Fri Jan 13 22:56:08 2023 +0100
@@ -5,7 +5,7 @@
55
66 ditaa
77
8- |
8+ Max |
99 V
1010 +-------*---\ /-----------\ /-----------\ /-----------\ /-----------\ /-----------+
1111 | Generator | | Sieve(2) | | Sieve(3) | | Sieve(5) | : | | Finder |
@@ -13,6 +13,6 @@
1313 | cBLU | | cGRE | | cGRE | | cGRE | | cGRE | | cPNK |
1414 +-----------/ \-----------/ \-----------/ \-----------/ \-----------/ \---------*-+
1515 |
16- 0 The shown (horizontal) connections all use the SimpleSieve protocol V
16+ 0 The shown (horizontal) connections all use the SimpleSieve protocol V Primes
1717 0 The Generator has a (in) port for the StartSieve protocol
1818 0 The Finder has an optional (out) port for SimpleSieve protocol
diff -r bb37490e83b0 -r 924a35e5b4bb CCastle/4.Blog/sieve-protocols-sidebar.irst
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/CCastle/4.Blog/sieve-protocols-sidebar.irst Fri Jan 13 22:56:08 2023 +0100
@@ -0,0 +1,16 @@
1+.. -*-rst-*-
2+ included in `b.TheSieve.rst`
3+
4+.. sidebar:: Sieve Protocols
5+
6+ .. code-block:: ReasonML
7+
8+ protocol SimpleSieve : Protocol {
9+ kind: event;
10+ input(int:try);
11+ }
12+
13+ protocol StartSieve : Protocol {
14+ kind: event;
15+ runTo(int:max);
16+ }