Package philosophers
philosophers-demo #sleela 2.5 (lib/philosophers/philosophers-demo.sleela)
PhilosophersDemo class
builds the canonical chain Constructor() :: Patch :: Constructor :: Aim :: Guide, weighs favor on the Notice of Approach, runs a time-bounded contract, and lets the object live free.
Methods — the actions this unit can perform.
| Method | Signature | What it does |
|---|---|---|
main | void main() | No description in source. |
SLConstructorContract #sleela 2.5 (lib/philosophers/SLConstructorContract.sleela)
SLConstructorContract class
The time-bounded contract of the instantiative moment -- the Constructor is of nature and time, and that moment does not outstay ~2 minutes.
Fields — the named values this unit stores.
| Field | Declaration | What it holds |
|---|---|---|
MAX_SECONDS | static final int MAX_SECONDS = 120 | --- the two-minute boundary and the phases of the moment --------------- The instantiative moment runs no more than about two minutes. |
PHASE_SEALED | static final int PHASE_SEALED = 0 | No description in source. |
PHASE_OPEN | static final int PHASE_OPEN = 1 | No description in source. |
PHASE_CLOSED | static final int PHASE_CLOSED = 2 | No description in source. |
PHASE_FREE | static final int PHASE_FREE = 3 | No description in source. |
clock | int clock | the clock of the moment, in seconds; only ever advanced ahead |
phase | int phase | the current phase of the moment |
free | int free | 1 once the object has been declared to live free of the moment |
Methods — the actions this unit can perform.
| Method | Signature | What it does |
|---|---|---|
create | void create() | Prepare a sealed contract. The moment has not opened. |
open | void open() | Open the instantiative moment. The clock starts at zero. |
tickAhead | int tickAhead(int seconds) | The perpetual whistle of time, kept as "ahead": advance the clock forward by a number of seconds. Backward or zero ticks are ignored (time only ever goes ahead). When the clock reaches the two-minute boundary the moment closes on its own. Returns the clock after the tick. |
withinContract | boolean withinContract() | Is the moment still inside its two-minute contract? |
clampSeconds | int clampSeconds(int seconds) | Clamp a requested duration (seconds) into [1, MAX_SECONDS]. Offered so a caller never has to name this class's MAX_SECONDS constant directly. |
maxSeconds | int maxSeconds() | The two-minute boundary, as a method, for callers that need the number. |
sealMoment | void sealMoment() | Close the moment deliberately (e.g. construction finished before 2 min). Named sealMoment() rather than close(): a bare close() collides with the reserved Munction reach-handle built-in, so the contract uses its own name. |
liberate | boolean liberate() | Declare the object free: it now lives on, released from the moment that made it. Only a closed moment can be freed; the whistle never runs back. |
livesFree | boolean livesFree() | No description in source. |
getClock | int getClock() | No description in source. |
getPhase | int getPhase() | No description in source. |
phaseText | String phaseText() | No description in source. |
SLFavorMechanism #sleela 2.5 (lib/philosophers/SLFavorMechanism.sleela)
SLFavorMechanism class
The Favor Mechanism -- it catches the facts and sayings of Approach at the time of the Constructor call and decides runnability.
Fields — the named values this unit stores.
| Field | Declaration | What it holds |
|---|---|---|
FAVOR_WITHHELD | static final int FAVOR_WITHHELD = 0 | --- favor verdicts ----------------------------------------------------- |
FAVOR_GRANTED | static final int FAVOR_GRANTED = 1 | No description in source. |
noticeCaught | int noticeCaught | the running tally of Notice caught at the Time of the call |
quorum | int quorum | the least Notice that must be caught for favor to be granted |
verdict | int verdict | the last verdict rendered (FAVOR_WITHHELD / FAVOR_GRANTED) |
Methods — the actions this unit can perform.
| Method | Signature | What it does |
|---|---|---|
create | void create() | Prepare the mechanism with a default quorum of one caught Notice. |
setQuorum | void setQuorum(int q) | Set how much Notice the Approach must earn before favor can be granted. A quorum below one is lifted to one: favor is never free. |
getQuorum | int getQuorum() | No description in source. |
catchNotice | void catchNotice(String saying) | Catch one fact/saying of Approach. Each caught Notice raises the tally. |
getNoticeCaught | int getNoticeCaught() | No description in source. |
weigh | int weigh() | Weigh the Notice and render a verdict. Favor is granted only when the caught Notice meets or exceeds the quorum. Returns the verdict code. |
granted | boolean granted() | No description in source. |
verdictText | String verdictText() | The verdict as readable text, for banners and contracts. |
reset | void reset() | Reset the mechanism for a fresh Constructor call, keeping the quorum. |
SLOrdain #sleela 2.5 (lib/philosophers/SLOrdain.sleela)
SLOrdain class
Ordain -- the ordinality itself. Not a Guide and not a seating, but the orthogonal principle of rank and order that stands across all twenty-one seatings at once.
Fields — the named values this unit stores.
| Field | Declaration | What it holds |
|---|---|---|
CROWN | static final int CROWN = 20 | --- the axis of order ---------------------------------------------------- The ordaining crown: the seating the whole chain answers to (Approval). |
FLOOR | static final int FLOOR = 0 | The floor of the register: the first seating (Approach). |
CATEGORIES | static final int CATEGORIES = 7 | The number of categories that Ordain ranks over the sequence. |
register | SLPhilosopherSeating register | the register whose order Ordain reads (orthogonal, not seated within it) |
Methods — the actions this unit can perform.
| Method | Signature | What it does |
|---|---|---|
create | void create() | Prepare the ordinality over a fresh register. |
readOver | void readOver(SLPhilosopherSeating r) | Read over an existing register instead of the fresh one. |
ordains | boolean ordains(int ordinal) | Is this ordinal ordained (a real, ranked seating)? Orthogonality means Ordain itself is never one of them, so it answers about others only. |
rank | int rank(int ordinal) | The rank of an ordinal: its distance up from the floor (0 at Approach, 20 at Approval). This is the ordinality -- the order-number of the seat. |
toCrown | int toCrown(int ordinal) | How near a seating stands to the ordaining crown: 0 at the crown itself, growing with distance below it. The chain answers upward, so nearness to the crown is nearness to Approval. |
ordainingCategory | int ordainingCategory(int ordinal) | The category that ordains a seating (which of the seven phases ranks it). |
ordainingCategoryName | String ordainingCategoryName(int ordinal) | No description in source. |
isCrown | boolean isCrown(int ordinal) | Is this the ordaining crown itself (Approval, the seat answered to)? |
reading | String reading(int ordinal) | A one-line reading of an ordinal's place in the order, e.g. "Aim: rank 6, category Intent, 14 below the crown (Approval)". |
SLPackage #sleela 2.5 (lib/philosophers/SLPackage.sleela)
SLPackage class
Defines the SLeeLa standard-library package for philosophers.
Fields — the named values this unit stores.
| Field | Declaration | What it holds |
|---|---|---|
MODULE | static final String MODULE = "philosophers" | No description in source. |
Methods — the actions this unit can perform.
| Method | Signature | What it does |
|---|---|---|
moduleName | String moduleName() | No description in source. |
SLPhilosopherChain #sleela 2.5 (lib/philosophers/SLPhilosopherChain.sleela)
SLPhilosopherChain class
A Constructor's chain of growths, written with "::" between one growth and the next -- Constructor() :: Patch :: Constructor :: Aim :: Guide.
Fields — the named values this unit stores.
| Field | Declaration | What it holds |
|---|---|---|
GROWTH | static final String GROWTH = " :: " | the growth separator: one growth :: the next |
ROOT | static final String ROOT = "Constructor()" | the base of the chain is always a Constructor() call |
seating | SLPhilosopherSeating seating | the seating register governing how many Guides this chain may hold |
guides | SLPhilosopherGuide[] guides | the Guides of this chain, in order (index 0 is the first after the root) |
count | int count | how many Guides have been seated |
refusedFlag | int refusedFlag | 1 if a seat request was refused because the chain was at capacity |
Methods — the actions this unit can perform.
| Method | Signature | What it does |
|---|---|---|
create | void create() | Prepare an empty chain at the default (band 0 -> 21) capacity. |
admit | int admit(int band) | Admit a signed band of additional seatings before building the chain. Returns the band actually admitted (clamped into [-2,+6]). |
capacity | int capacity() | No description in source. |
size | int size() | No description in source. |
refused | boolean refused() | No description in source. |
seat | int seat(String guideName, int seatOrdinal, boolean carriesFavor) | Seat one named Guide onto the given seating ordinal. An approving Guide carries favor (Gold); a growing Guide carries Green. Returns the Guide's index, or -1 when the chain is already at its admitted capacity. |
at | SLPhilosopherGuide at(int i) | No description in source. |
broadcast | int broadcast(String impart) | Broadcast one context/impart to every seated Guide; each matching Guide counts the match. Returns how many Guides matched this impart. |
disposeAll | void disposeAll() | Dispose every Guide after the object lives free. Idempotent per Guide. |
render | String render() | Render the canonical chain text, e.g. "Constructor() :: Patch :: Constructor :: Aim :: Guide". Built with "+" so no bridged char op is needed; this is the text an editor colors. |
colorManifest | String colorManifest() | A compact color manifest for the editor: the color impart of each Guide in order, joined with "::", e.g. "Gold/Yellow :: Green :: Gold/Yellow". |
SLPhilosopherConstructor #sleela 2.5 (lib/philosophers/SLPhilosopherConstructor.sleela)
SLPhilosopherConstructor class
The perfect Constructor -- it seats its Guides, opens a time-bounded contract, weighs favor, runs, and then lets the object live free.
Fields — the named values this unit stores.
| Field | Declaration | What it holds |
|---|---|---|
chain | SLPhilosopherChain chain | the chain of growths this Constructor declares |
favor | SLFavorMechanism favor | the Favor Mechanism that weighs Notice at call time |
contract | SLConstructorContract contract | the time-bounded contract of the instantiative moment |
ran | int ran | 1 once the Constructor has actually run to completion |
Methods — the actions this unit can perform.
| Method | Signature | What it does |
|---|---|---|
create | void create() | Prepare the Constructor with an empty chain, a fresh Favor Mechanism, and a sealed contract. |
admit | int admit(int band) | Admit a signed seating band in [-2,+6]; returns the band admitted. |
guide | int guide(String name, int seatOrdinal, boolean carriesFavor) | Seat one named Guide; returns its index or -1 when at capacity. |
requireNotice | void requireNotice(int quorum) | Set how much Notice the Approach must earn for favor. |
run | boolean run(String[] imparts, int seconds) | Run the instantiative moment. The caller first provides the facts/sayings of Approach as imparts; this method opens the contract, broadcasts each impart to the Guides, catches the matched Notice into the Favor Mechanism, weighs favor, and -- only on granted favor -- runs for the given duration, closes the moment, disposes the Guides, and liberates the object. Returns true when the object was constructed and now lives free. |
constructed | boolean constructed() | No description in source. |
chainText | String chainText() | --- output surface ----------------------------------------------------- |
colorManifest | String colorManifest() | No description in source. |
verdict | String verdict() | No description in source. |
clock | int clock() | No description in source. |
phase | String phase() | No description in source. |
capacity | int capacity() | No description in source. |
guides | int guides() | No description in source. |
report | String report() | A single-line report of quality, effect and output after construction. |
SLPhilosopherGuide #sleela 2.5 (lib/philosophers/SLPhilosopherGuide.sleela)
SLPhilosopherGuide class
One Guide -- a single growth in a Constructor's chain, with its color impart and its listener for contexts and imparts.
Fields — the named values this unit stores.
| Field | Declaration | What it holds |
|---|---|---|
COLOR_NONE | static final int COLOR_NONE = 0 | No description in source. |
COLOR_GOLD | static final int COLOR_GOLD = 1 | No description in source. |
COLOR_GREEN | static final int COLOR_GREEN = 2 | No description in source. |
name | String name | --- a Guide's own name, seating and impart ----------------------------- the name as written in the chain, e.g. "Patch", "Aim", "Guide" |
seat | int seat | the seating ordinal this Guide claims (see SLPhilosopherSeating) |
approving | int approving | 1 when this Guide carries approving favor forward, else 0 |
matched | int matched | a small count of contexts/imparts this Guide has matched so far |
disposed | int disposed | 1 once this Guide has been disposed after the object lives free |
Methods — the actions this unit can perform.
| Method | Signature | What it does |
|---|---|---|
create | void create() | Prepare an empty, uncolored Guide. |
sit | void sit(String guideName, int seatOrdinal, boolean carriesFavor) | Name a Guide onto a seating. An approving Guide carries favor (Gold); a still-growing Guide carries Green. |
getName | String getName() | No description in source. |
getSeat | int getSeat() | No description in source. |
isApproving | boolean isApproving() | No description in source. |
getMatched | int getMatched() | No description in source. |
color | int color() | The editor color impart for this Guide. Idempotent: the same Guide always reports the same color for the same impart, and asking never mutates it. |
colorName | String colorName() | The color impart as text, for banners and editor manifests. |
listen | boolean listen(String impart) | Listen for a context/impart at Constructor-call time. A Guide matches when the impart is non-null and names this Guide's seating or its own name; the match is counted so the Favor Mechanism can weigh Notice over Time. |
dispose | void dispose() | Dispose this Guide after the object lives free of its instantiative moment. Disposal is idempotent and produces the Guide's final effect: it stops listening and keeps its matched tally as its output of record. |
isDisposed | boolean isDisposed() | No description in source. |
SLPhilosopherSeating #sleela 2.5 (lib/philosophers/SLPhilosopherSeating.sleela)
SLPhilosopherSeating class
The twenty-one catalogued "seatings" a perfect Constructor can admit -- each a Guide/Wisdom slot that governs the maturation of principle over a static constructor.
Fields — the named values this unit stores.
| Field | Declaration | What it holds |
|---|---|---|
BASE_SEATINGS | static final int BASE_SEATINGS = 21 | --- the finitude of a perfect Constructor ------------------------------ BASE seatings that every perfect Constructor approves by default. |
ADDITIONAL_MIN | static final int ADDITIONAL_MIN = -2 | The signed band of additional seatings a Constructor may admit. |
ADDITIONAL_MAX | static final int ADDITIONAL_MAX = 6 | No description in source. |
MIN_CAPACITY | static final int MIN_CAPACITY = 19 | Admitted capacity therefore lives in [MIN_CAPACITY, MAX_CAPACITY]. |
MAX_CAPACITY | static final int MAX_CAPACITY = 27 | No description in source. |
SEAT_APPROACH | static final int SEAT_APPROACH = 0 | No description in source. |
SEAT_NOTICE | static final int SEAT_NOTICE = 1 | No description in source. |
SEAT_WARRANT | static final int SEAT_WARRANT = 2 | No description in source. |
SEAT_PATCH | static final int SEAT_PATCH = 3 | No description in source. |
SEAT_SEED | static final int SEAT_SEED = 4 | No description in source. |
SEAT_FRAME | static final int SEAT_FRAME = 5 | No description in source. |
SEAT_AIM | static final int SEAT_AIM = 6 | No description in source. |
SEAT_COURSE | static final int SEAT_COURSE = 7 | No description in source. |
SEAT_MEASURE | static final int SEAT_MEASURE = 8 | No description in source. |
SEAT_HEALTH | static final int SEAT_HEALTH = 9 | No description in source. |
SEAT_VIGOR | static final int SEAT_VIGOR = 10 | No description in source. |
SEAT_PATTERN | static final int SEAT_PATTERN = 11 | No description in source. |
SEAT_GUIDE | static final int SEAT_GUIDE = 12 | No description in source. |
SEAT_MINISTRY | static final int SEAT_MINISTRY = 13 | No description in source. |
SEAT_COUNSEL | static final int SEAT_COUNSEL = 14 | No description in source. |
SEAT_OFFICE | static final int SEAT_OFFICE = 15 | No description in source. |
SEAT_SAINT | static final int SEAT_SAINT = 16 | No description in source. |
SEAT_FAVOR | static final int SEAT_FAVOR = 17 | No description in source. |
SEAT_IMPART | static final int SEAT_IMPART = 18 | No description in source. |
SEAT_CONFORM | static final int SEAT_CONFORM = 19 | No description in source. |
SEAT_APPROVAL | static final int SEAT_APPROVAL = 20 | No description in source. |
CAT_ADMISSION | static final int CAT_ADMISSION = 0 | --- the seven categories (the ordinal ternary phases) ------------------- |
CAT_INCEPTION | static final int CAT_INCEPTION = 1 | No description in source. |
CAT_INTENT | static final int CAT_INTENT = 2 | No description in source. |
CAT_VITALITY | static final int CAT_VITALITY = 3 | No description in source. |
CAT_GOVERNANCE | static final int CAT_GOVERNANCE = 4 | No description in source. |
CAT_STANDING | static final int CAT_STANDING = 5 | No description in source. |
CAT_CLOSURE | static final int CAT_CLOSURE = 6 | No description in source. |
additional | int additional | the number of additional seatings this register has admitted, in band |
capacity | int capacity | admitted capacity = BASE + additional, clamped to [MIN, MAX] |
Methods — the actions this unit can perform.
| Method | Signature | What it does |
|---|---|---|
create | void create() | Prepare the register at the default (band = 0) capacity. |
admit | int admit(int band) | Admit a signed number of additional seatings. Out-of-band requests are clamped into [ADDITIONAL_MIN, ADDITIONAL_MAX]; the method returns the band actually admitted so the caller learns the truth rather than a silent lie. |
getCapacity | int getCapacity() | No description in source. |
getAdditional | int getAdditional() | No description in source. |
seats | boolean seats(int ordinal) | Is an ordinal a real seating in the current admitted capacity? |
inBand | boolean inBand(int band) | Is a band value inside the signed admission band? |
seatName | String seatName(int ordinal) | The human name of a baseline seating ordinal, or "unseated" past 20. |
category | int category(int ordinal) | The category ordinal (0..6) of a baseline seating, or -1 if unseated. Each category holds three consecutive seatings, so the category is the seating ordinal divided by three. |
categoryName | String categoryName(int cat) | The human name of a category ordinal (0..6), or "none". |
seatCategoryName | String seatCategoryName(int ordinal) | The category name of a seating ordinal directly, or "none" if unseated. |