From 2a64fcb1cf1efdfd069bab459f1542710ca4bc0b Mon Sep 17 00:00:00 2001 From: Helmut Merz Date: Sun, 26 Apr 2026 22:34:01 +0200 Subject: [PATCH] csys: work in progress: programs and stages --- lib/csys/program.ex | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/lib/csys/program.ex b/lib/csys/program.ex index a9c10a6..c8d3138 100644 --- a/lib/csys/program.ex +++ b/lib/csys/program.ex @@ -17,18 +17,8 @@ defmodule Scopes.CSys.Program do # processors - def notify(msg, scope) do - Environ.notify(env(scope), msg) - end - - def forward(msg, scope) do - Enum.reduce(syns(scope), false, fn s, _acc -> s.(msg); true end) - end - def std_proc({:parent}, scope) do - env = env(scope) - syn = synapse(self(), &Function.identity/1, 0) - new = neuron({[], Environ.get_stage(env, :basic, :initial), [syn], env}) + new = create_parent(env(scope)) notify({:created, new}, scope) end @@ -43,4 +33,21 @@ defmodule Scopes.CSys.Program do def std_proc(msg, scope) do forward(msg, scope) || notify(msg, scope) end + +# processor steps + + def notify(msg, scope) do + Environ.notify(env(scope), msg) + end + + def forward(msg, scope) do + Enum.reduce(syns(scope), false, fn s, _acc -> s.(msg); true end) + end + +# step functions + + def create_parent(env) do + syn = synapse(self(), &Function.identity/1, 0) + neuron({[], Environ.get_stage(env, :basic, :initial), [syn], env}) + end end