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

Self Hook #258

Open robcxyz opened 8 months ago

robcxyz commented 8 months ago

Self Hook

Create a special self hook to reference the hook's methods during parsing

Overview


MyHook<-:

  foo: bar

  a_method:

    bar: bar

  exec:

    get_a_method->: self a_method --merge

call->: MyHook --foo baz

self<-:

  foo:

    type: str

    default: baz

#  ...

self as Hook

If self was a hook it would be simple to implement but the issue is we need to know that we are inside a hook from the context, otherwise if self is called, within that hook it will not know that it is in fact executing within another hook. For instance:


Foo<-:

  bar: baz

  Method<-: ...

  exec:

    do->: self Method

Inside do we don't know that we are within an exec of another hook. If we did know that, we could easily build the hook