Skip to content

Attribute blocks #423

Open
jckarter opened this Issue Oct 16, 2012 · 4 comments

1 participant

@jckarter
Owner

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) {}
}
@ghost
ghost commented Oct 16, 2012

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?

@jckarter
Owner

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.

@ghost
ghost commented Oct 22, 2012

What about mixing predicates & multiple attributes?

[T when Bar?(T)] inline {
    ...
}
@jckarter
Owner

If we're going to allow either predicate or attribute blocks, allowing both together makes sense.

@ghost Unknown referenced this issue Oct 28, 2012
Closed

Get rid of overload keyword #410

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.