sudoblockio / tackle

Tackle is a programmable configuration language for building modular utilities, code generators, and CLIs with schema validation baked in.
Apache License 2.0
51 stars 2 forks source link

Private + Bare `exec` Method (ie `exec<_` / `exec`) #248

Open robcxyz opened 8 months ago

robcxyz commented 8 months ago

Private + Bare exec Method (ie exec<_ / exec)

None

Overview

The exec method on a declarative hook is special in that when it exists, the return of the hook is public data from parsing it. This is how we can make dcl hooks into functions with typed inputs. For example:


a_hook<-:

  foo: bar

  exec:

    stuff: things

run_hook->: a_hook

assert->: a_hook {'stuff':'things}

Currently, when processing this method, we run a macro such that the field exec is transformed to exec<- which is a public method. If an exec method exists, then only the public data from the exec execution is returned as is shown in the above example (ie {'stuff': 'things'}).

This proposal opens up the idea of what various exec methods behave when called bare (exec), publicly (exec<-), and privately (exec<_). It is centered around the notion of what happens to the fields in the hook in response to various exec methods.

Proposal

There are three general options which are possible with the following outcomes.

Values of different types can be used as well.

Examples

Bare

Only the exec method's public data.


a_hook<-:

  foo: bar

  exec:

    stuff: things

expected_output:

  stuff: things

assert->: {{a_hook()}} {{expected_output}}

Public

Both the exec method's public data and the fields.


a_hook<-:

  foo: bar

  exec->:

    stuff: things

expected_output:

  foo: bar

  stuff: things

assert->: {{a_hook()}} {{expected_output}}

Private

Only the field's data.


a_hook<-:

  foo: bar

  exec_>:

    stuff: things

expected_output:

  foo: bar

assert->: {{a_hook()}} {{expected_output}}