I'm not a big fan of* p = Point(); p.x = 1.0*, since it might sneak in undefined reference errors, which seems totally avoidable to me. You can always do this, after all: *x = compute_x()* *....* *y = compute_y()* *....* *Point(x,y)*
If performance is your concern, I'm pretty sure that LLVM is smart enough about it to not make this perform any slower. Am Freitag, 4. September 2015 18:49:47 UTC+2 schrieb Ferran Mazzanti: > > Dear all, > I was wonder if it is possible to do in Julia what I can do in other > languages, such as define a user type, as for instance > > type Point > x::Float64 > y::Float64 > end > > and then define a new varible of that type, but do not initialize it, as in > > z::Point > > which obviously doesn't work (unless in the local scope of a function, > with z being passed as an argument to the function). > > I ask because I am used to use pointers (in other languages), declare the > pointer, allocate room for the object, and then > use an instance of the object and initialize the different components in > the order I like. I mean to say something of the form, inventing my > own instructions :) > > ype Point > x::Float64 > y::Float64 > end > z::Point > allocate(z) > z.y = 2.0 > z.x = 3.1 > > In Julia the only way I know to initialize the object is to pass values to > it in exactly the same order the different fields appear in the > type deffinition. Look as I have changed this order in my invented piexe > of code... > > Any hint appreciated. > > Thanks. >