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
53 stars 2 forks source link

Hook Instantiation #238

Open robcxyz opened 10 months ago

robcxyz commented 10 months ago

Hook Instantiation

Open the concept of using methods on instantiated hooks

Overview

When calling methods, in the past we have opted for converging the fields of method into the base like this.


hook<-:

  foo: str

  method<-:

    bar: str

h->: hook method --foo a --bar b

#h:

#  bar: b

#  foo: a

But that is really a macro version of this


hook<-:

  foo:

    type: str

...

Which could also have properties that inform whether the the field is inherited.


hook<-:

  foo:

    type: str

    passed: true

  method<-:

    bar: str

h->: hook method --foo a --bar b

#h:

#  bar: b

#  foo: a

And allow us to have more control over how the object is used.


hook<-:

  foo:

    type: str

    passed: false  # Default could be true?

  method<-:

    bar: str

h->: hook method --bar b # This now complains no foo

But I think it also opens up the possibility of discriminating between a couple of things.

Both these concepts are related.

instantiated vs uninstantiated hook

We should be able to populate a hook and then call a method on it.


hook<-:

  foo:

    type: str

    passed: true

  method<-:

    bar: str

h->: hook --foo a

g->: h method --bar b

But right now that is not possible for a couple reasons

Options: