Attribute blocks
As suggested by @galchinsky, it would be useful to be able to collect top level definitions with common attributes into a block, to eliminate repetition:
forceinline {
foo() {}
bar() {}
}
[T when Foo?(T)] {
foo(x:T) {}
bar(x:T) {}
}
This had already been proposed and I had considered implementing it a few months ago. However the natural progression lead to nesting of these groups which looked a bit messy. Would you allow attribute/predicate refinement within the proposed blocks?
Arbitrary nesting seems like overkill. Allowing simple refinement seems doable. If a definition in a predicated block has an additional predicate, consider it to have the and of the block's and the definition's predicate. So:
[T when Sequence?(T)] {
[E when SequenceElementType(T) == E] push(seq:T, elt:E) { ... }
}
would be equivalent to:
[T, E when Sequence?(T) and SequenceElementType(T) == I]
push(seq:T, elt:E) { ... }
Attribute sets would be unioned. More complex combinations shouldn't be required, because you can always not use blocks if they aren't appropriate.
What about mixing predicates & multiple attributes?
[T when Bar?(T)] inline {
...
}
If we're going to allow either predicate or attribute blocks, allowing both together makes sense.