Code with Plans

Code with Plans

Use rules as functions and plans as calls, and you have a minimal, vectorized functional programming language! Let's break it down:

The name field

Ah, the hardest part of coding, naming things! Well, you have to name them something, and this is a good place for it. You know the function name(...) from other languages, and that a function is no fun unless you have a reference to it.

The head field

Think of this as what may be called things like #include or @macro in other languages. It's a list of static code dependencies, which means that you get to reuse and patch together code: Rules can act as structs by just holding constants, perform some dynamic calculations, string together some other calculations, and mix these roles.

The args field

This is where you can map distributions to units, and thereby get a whole lot of numbers that mean different things to you into your code. When a list of dependencies is resolved (refer back to head), these args act as defaults for each other. For every dependency that has defined something in Meters, for example, the last one gets to override any other.

The unit field

This one is simple, your return type. Any rule is forced to return one vector of numbers, and this label is what you want to interpret those numbers as.

The func field

Inject your linear algebra here! You cannot call other rules in this scope, but you do get to have some algebraic fun with [Your] + [Own units] * [This way]

# Examples:
[Velocity] * [Duration] # Length!
√([Area50] + [Area51]) + ∛([Volume1] + [Volume2]) # Also length :)
sin([Phase]) # The length of a pendulum in motion from its center? 🤓
fallback([Condition], [Value]) # A transistor - Turing complete ✅

# and infinities more ...

Advanced

That's it for the fundamentals. But as it is for the six strings and some frets on a guitar, we haven't even begun to play with them yet :)

#=
  TODO:
  show JSON examples, explain types,
  and what you can do with the more advanced fields below
=#
struct Step
    id::String
    name::String
    type::String
    will::Int
    args::OrderedDict{String,String}
    vars::OrderedDict{String,String}
    head::Vector{String}
    func::Vector{String}
    unit::String
    body::Vector{Vector{String}}
    tail::Vector{Vector{String}}
    star::Vector{String}
    bins::Vector{Bool}
    lump::Bool
    correlations::Vector{Correlation}
    applications::Dict{String,Int}
    pass::Bool
    index::Int
    count::Int
    steps::Vector{Step}
end