Skip to content

Avoiding lambdas with capture #8

Description

@majg0

Hi Raph! Great work!

At my work we use a custom language which does not support captures in lambdas. Instead we have simple definitions of semantic macros.

Reading the counter.rs source therefore had me wonder... how about an alternative API using begin/end calls instead? I assume the main reason for callbacks is safety: not missing a matching end call.

Matching begin/end using Rust macros might provide increased confusion in traces.
If we just don't enforce this at compile time, control flow could become visibly simpler and more open and powerful, not being coupled to function boundaries. This could also open up for more complex composition.

I think it's a tradeoff worth pondering, despite not necessarily being idiomatic Rust. What do you think?

I'm considering e.g. crashing at runtime if a node ends up unclosed, together with some simple API like cx.push(MyContainer::new()); { ... } cx.pop(); or something similar.

Would love to hear your thoughts on this!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions