As a feature proposal that sounds good, and as you can see there is plenty of activity in the community to address such need. None of them is mature and/or widely accepted enough to be included in the language though(and there is plenty of argument to keep developing such features in separate packages).
More standard (in julia) is to define “interfaces”, i.e. common set of functions that some objects share, see e.g. iteration, AbstractArray
, AbstractDict
or else. While I’d like to see more of these efforts (what is needed for MyCrazyFloat
to behave like AbstractFloat
?) I don’t need these to be imposed on the type/signature level, or read them directly in code. To me such descriptions are best read in the documentation in natural language than from the templates. (Again my limited experience with C++ may compound my aversion to the latter:) )
As I understand the problem now it is more of
I need a way to tell my users (and myself) what do I expect from inputs to my software
The proposed static annotation is one of many solutions (which comes with its price of making code less readable). Another one is writing good documentation (price: maintaining the sync of docs and code). Let me add another solution to the problem: define your specification/protocols in a lightweight package and create a testset to test it. That’s the solution I myself used for GitHub - kalmarek/GroupsCore.jl: Interface for abstract groups
There it is, versioned, dependable and testable specification! But of course we’ll see how it fares in the future