Re: [julia-users] Interfaces like in Go
There is no official/formal way. But have a look at base/graphics.jl for an ad hoc way of specifying an interface. I think it's the only place in base where this is done, so I'm not sure how julian this is. Also, I think Leah thought of adding some functionality to infer the interface of a type after the fact. Not sure whether that is in place already: https://github.com/astrieanna/TypeCheck.jl On Thu, 2014-03-27 at 02:12, dluna...@gmail.com wrote: I really like how interfaces work in Go and I was wondering if there's a similar way to express this in Julia. For those who are unfamiliar with Go interfaces they're essentially types defined by behaviour (functions) and not by fields. So for example the ReadWriter interface implements the Read and Write method, other defined types that have a Read and Write method can be considered a ReadWriter. Dom
Re: [julia-users] Interfaces like in Go
Yeah abstract types seem to be the best place to implement something like this since, at least to my knowledge it wouldn't fundamentally break anything. You would still be able to define abstract types as is but you would also have the added power to further refine the behaviour of that type. On Thursday, March 27, 2014 4:53:26 AM UTC-4, Tobias Knopp wrote: In my opinion it would be worth adding some syntax for defining an interface for abstract types. It should give us nice error messages and clean way to document an interface. This is quite similar to the C++ concepts but as it is already possible to restrict the template parameter in Julia, the only missing thing is to define the interface for an abstract type.
Re: [julia-users] Interfaces like in Go
The Graphs.jl package has a slightly different implementation of interfaces. Again, it's not an official solution, just a way to address the issue. Kevin On Thursday, March 27, 2014, Dom Luna dluna...@gmail.com wrote: Yeah abstract types seem to be the best place to implement something like this since, at least to my knowledge it wouldn't fundamentally break anything. You would still be able to define abstract types as is but you would also have the added power to further refine the behaviour of that type. On Thursday, March 27, 2014 4:53:26 AM UTC-4, Tobias Knopp wrote: In my opinion it would be worth adding some syntax for defining an interface for abstract types. It should give us nice error messages and clean way to document an interface. This is quite similar to the C++ concepts but as it is already possible to restrict the template parameter in Julia, the only missing thing is to define the interface for an abstract type.
[julia-users] Interfaces like in Go
I really like how interfaces work in Go and I was wondering if there's a similar way to express this in Julia. For those who are unfamiliar with Go interfaces they're essentially types defined by behaviour (functions) and not by fields. So for example the ReadWriter interface implements the Read and Write method, other defined types that have a Read and Write method can be considered a ReadWriter. Dom