Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
robcxyz opened this issue Jan 1, 2024 · 0 comments
Open

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

robcxyz opened this issue Jan 1, 2024 · 0 comments
Labels
proposal Proposal for changes in syntax / behaviour wip A work in progress proposal

Comments

@robcxyz
Copy link
Collaborator

robcxyz commented Jan 1, 2024

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.

  • Bare exec -> Returns on the public data

  • Public method exec<- -> Returns the fields along with the public data

  • Private method exec<_ -> Returns only the fields and none of the exec method

  • Public hook call exec-> -> Call as if it is a hook

  • Private hook call exec_> -> Call as if it is a hook with --no_output

Values of different types can be used as well.

  • Dict bare + methods -> walk

  • Dict hook call -> block

  • String bare + methods ->

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}}
@robcxyz robcxyz changed the title tmp Exec Method Arrows Jan 1, 2024
@robcxyz robcxyz added proposal Proposal for changes in syntax / behaviour wip A work in progress proposal labels Jan 1, 2024
@robcxyz robcxyz changed the title Exec Method Arrows Private + Bare exec Method (ie exec<_ / exec) Jan 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposal Proposal for changes in syntax / behaviour wip A work in progress proposal
Projects
None yet
Development

No branches or pull requests

1 participant