I didnt respond because I was writing template stuff that would do the same thing as example, but then I failed, because it would include stuff I would really not want to compile(parse ambiguity mostly), but this could technically be done with concepts:
template <type T, type U>
concept ContainerValue
method T.operator[] takes integer returns U
endconcept
template <type Container, type U> requries ContainerValue<Container, U>
function foo takes Container c, U initValue returns nothing
endfunction
Also what about the C++ concept as template argument style?
template <type T>
concept Printable
method T.print takes nothing returns nothing
endconcept
template <Printable P>
function f takes P p returns nothing
call p.print()
endfunction
.
Also just now thinking about having Or-ing in the concepts, so the Printable concept would require EITHER method print OR function Print, something like this
template <type T>
concept Printable
or{
method T.print takes nothing returns nothing
function Print takes T returns nothing
}
endconcept
?