|
Up until now it's been the realm of PL research. The Ptolemy language is one example I know of: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.86.... [PDF] If you're familiar with duck typing, behavioral typing is (in essence) the reification of duck typing in a concrete type system. In other words, instead of specifying the type of your argument as "Array", you could specify "some type that is indexable, iterable, and can be appended to". In Julia (mind you this was just the idea I saw being considered), today you would do: function foo(myarray::AbstractArray)
...
end
but in the future you might be able to do something like: function foo(myarray::ANY{getindex(), setindex(), iterate(), append()})
...
end
what's really neat, though, is combining this with type aliases, you could have: typealias Arraylike ANY{getindex(), setindex(), iterate(), append()}
function foo(myarray::Arraylike)
...
end
|
[0]: https://dzone.com/articles/duck-typing-scala-structural