csys: work in progress: programs and stages

This commit is contained in:
Helmut Merz 2026-04-26 22:34:01 +02:00
parent 157c013c44
commit 2a64fcb1cf

View file

@ -17,18 +17,8 @@ defmodule Scopes.CSys.Program do
# processors # 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 def std_proc({:parent}, scope) do
env = env(scope) new = create_parent(env(scope))
syn = synapse(self(), &Function.identity/1, 0)
new = neuron({[], Environ.get_stage(env, :basic, :initial), [syn], env})
notify({:created, new}, scope) notify({:created, new}, scope)
end end
@ -43,4 +33,21 @@ defmodule Scopes.CSys.Program do
def std_proc(msg, scope) do def std_proc(msg, scope) do
forward(msg, scope) || notify(msg, scope) forward(msg, scope) || notify(msg, scope)
end 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 end