Re: [julia-users] Re: Julia equivalent to a static member function in C++/MATLAB

2015-09-26 Thread Joel Andersson
Yes, this is all clear. Joel

[julia-users] Re: Julia equivalent to a static member function in C++/MATLAB

2015-09-25 Thread Steven G. Johnson
On Friday, September 25, 2015 at 11:56:46 AM UTC-4, Joel Andersson wrote: > > Hi, > > In C++ or in MATLAB I would use static member functions to keep the > constructors nice and simple, e.g. > class MyMatrix { > public: > static MyMatrix zeros(int n, int m); > static MyMatrix ones(int n,

[julia-users] Re: Julia equivalent to a static member function in C++/MATLAB

2015-09-25 Thread 'Greg Plowman' via julia-users
> In Julia, you can do the same thing, it is just spelled differently. You > could do x = zeros(MyMatrix, 3, 4) where you have defined Base.zeros(::Type{MyMatrix}, m, n) = . Show trimmed content Of course in Julia you can do anything you want. However, is it recommended to

[julia-users] Re: Julia equivalent to a static member function in C++/MATLAB

2015-09-25 Thread Eric Forgy
You probably know this, but the way dispatch works in Julia, it will look for a function matching the signatures. Since, presumably, MyMatrix is not in base Julia, that zeros function will do whatever you want it to do because you have yo implement it.