context-capabilities-initiative icon indicating copy to clipboard operation
context-capabilities-initiative copied to clipboard

How to set multiple capabilities on a single line?

Open yoshuawuyts opened this issue 2 years ago • 1 comments

The "Bundling and Splitting" section covers how to combine context capabilities on the declaration side. E.g.

context foo;
context bar;
context baz;

context kaboodle = foo + bar + baz;

On the declaration side we know that we want to enable "with clauses anywhere where clauses can be used", and I think we have a good sense for what we want from it. Something which we haven't covered yet is how to handle multiple capabilities on the consumer side. With the current syntax, we'd probably expect at least the following to work to set multiple capabilities:

with foo {
    with bar {
        with baz {
            // use `foo`, `bar` and `baz` here.
        }
    }
}

But this is very nested and doesn't necessarily feel great. Also in function bodies we don't have this issue because we can already set multiple context capabilities using a single with clause:

fn qux()
with foo, bar, baz,
{
    // use `foo`, `bar` and `baz` here.
}

There's a question of if and how we might want to support this for with blocks as well. Should we allow something like the following?:

with foo, bar, baz {
    // use `foo`, `bar` and `baz` here.
}

I don't think answering this is a priority, but it does feel like something we should track and find an answer for eventually.

yoshuawuyts avatar Jan 11 '22 18:01 yoshuawuyts

I like using commas in both contexts!

tmandry avatar Jan 11 '22 21:01 tmandry