ahdinosaur / rimu

Template language for structured data: functional YAML 🌱
https://rimu.dev
Apache License 2.0
38 stars 0 forks source link

defining and calling functions #9

Closed ahdinosaur closed 1 year ago

ahdinosaur commented 1 year ago

Operators:

but the question is: how do we "render" a Template::Function if we return a Value and there's no Value::Function?

ahdinosaur commented 1 year ago

okay i tried https://github.com/ahdinosaur/rimu/tree/functions but nah

new plan sketch:

  1. rimu-expr
    • define Expression
  2. rimu-value
    • define Function
    • Function is struct with "name" (String), "args" (Vec<String>) "body" (Expression)
  3. rimu-env
    • defines Environment (previously Context)
  4. rimu-expr-parse
    • parse String to Expression
  5. rimu-expr-eval
    • evaluates Expression (with Environment) to Value
  6. rimu
ahdinosaur commented 1 year ago

a side thought, is if Expression ends up being fully featured, then a Block (previously Operation) could end up just returning the Expression that represents itself, a Template could return the Expression that represents itself.

ahdinosaur commented 1 year ago

https://github.com/zesterer/chumsky/blob/main/examples/nano_rust.rs