4 ms·
Most dynamic OOP languages don't have interfaces either, so that is kind of a poor argument. You cannot compare Julia to something like Java. You got to compar
by socialdemocrat 6y ago
Most dynamic OOP languages don't have interfaces either, so that is kind of a poor argument. You cannot compare Julia to something like Java.
You got to compare it to Ruby, Python etc.
Also I have no idea what an interface definition would look like in Julia. A function in Julia isn't bound to one specific type like in an OOP language.
- newen 6y agoI think interfaces in Julia might go something like interface AnimalActions function walk(x::Animal) end function call(x::Animal, y::Animal) end function eat(x::Animal, z::Food) end end struct Dog <: Animal name::String end AnimalActions.walk(x::Dog) = true AnimalActions.call(x::Dog, y::Animal) = true AnimalActions.eat(x::Dog, z::Food) = true setinterface Dog AnimalActions end and then I guess using it like using AnimalActions d = Dog("rufus") walk(d)
- dklend122 6y agoThe below package implements something like that, but better imo: https://tk3369.github.io/BinaryTraits.jl/dev/ https://tk3369.github.io/BinaryTraits.jl/dev/