It's interesting how certain posts cause everyone to jump at once! :-) On Wednesday, May 7, 2014, Kevin Squire <[email protected]> wrote:
> Since Julia doesn't have Python or C++ style classes, it would have to be > done in the ugly, error prone manner. :-) > > In all seriousness, types in Julia are like C structs. Classes (in other > languages) are just structs with accociated functions, that have special > access to the members of the class (also known as single dispatch). > > There are no special functions in Julia that belong to or have access to > type members. Instead, members are always accessed using dot notation. > > Part of the reason for doing this is to enable multiple dispatch (which > none of Python, C++, or Fortran have), which allows functions to "belong > to" multiple types. Since there is not just one class that a function can > "belong to", functions don't have special access to type members. > > It's a different style of programming. I would suggest trying it and see > if you like it or not. Many others, myself included, find multiple dispatch > a useful trade for Python/C++ style objects, but if you don't like it, > there are plenty of other languages available. > > Cheers! > Kevin > > On Wednesday, May 7, 2014, Neal Becker > <[email protected]<javascript:_e(%7B%7D,'cvml','[email protected]');>> > wrote: > >> I've always used the following rule in languages such as python and c++ >> >> If an object has state, use a class. Otherwise use a function. >> >> In languages lacking classes (and objects) e.g., FORTRAN, state must be >> maintained outside of the object. This is ugly and error prone. >> >> How is this addressed in julia? >> >>
