Re: Struct constructor, opCall mess.

2014-02-25 Thread Remo
On Tuesday, 25 February 2014 at 07:59:33 UTC, Maxim Fomin wrote: On Monday, 24 February 2014 at 14:14:43 UTC, Tobias Pankrath wrote: On Monday, 24 February 2014 at 13:56:01 UTC, Remo wrote: Hi, right now I am truing to figure out how the constructors behave in D2. Question 1: why it is not

Re: Struct constructor, opCall mess.

2014-02-25 Thread Maxim Fomin
On Monday, 24 February 2014 at 14:14:43 UTC, Tobias Pankrath wrote: On Monday, 24 February 2014 at 13:56:01 UTC, Remo wrote: Hi, right now I am truing to figure out how the constructors behave in D2. Question 1: why it is not possible to create custom ctor for struct? The design of D reli

Re: Struct constructor, opCall mess.

2014-02-24 Thread Maxim Fomin
On Monday, 24 February 2014 at 19:41:57 UTC, Remo wrote: For Vector example this works pretty well this way. But my main problem is more complicated. extern(C) int init(ref CWrapper p); extern(C) void free(ref CWrapper p); struct CWrapper { //some data that must be the same at C side. Data

Re: Struct constructor, opCall mess.

2014-02-24 Thread Tobias Pankrath
On Tuesday, 25 February 2014 at 06:06:22 UTC, Jesse Phillips wrote: On Monday, 24 February 2014 at 20:35:54 UTC, Remo wrote: This looks like D2 is still in Beta stadium and not really ready for production use !? If someone thinks that C++ was production ready in 1998, just go and try a C++ co

Re: Struct constructor, opCall mess.

2014-02-24 Thread Jesse Phillips
On Monday, 24 February 2014 at 20:35:54 UTC, Remo wrote: This looks like D2 is still in Beta stadium and not really ready for production use !? I believe it is ready for production, but you can't expect it to be ready in all cases. Mostly its lack of readiness isn't because of the language th

Re: Struct constructor, opCall mess.

2014-02-24 Thread Jesse Phillips
On Monday, 24 February 2014 at 23:34:51 UTC, Remo wrote: Where I can find more info about 'D's move semantics'? Apparently it is not the same as rvalue reference and move semantics in C++11 ? Here is the place I know of: http://dconf.org/2013/talks/cehreli.html

Re: Struct constructor, opCall mess.

2014-02-24 Thread Remo
On Monday, 24 February 2014 at 21:06:03 UTC, monarch_dodra wrote: On Monday, 24 February 2014 at 17:15:10 UTC, Remo wrote: So what is proper/best way to mimic default constructor for struct ? Honestly, you can't, and you shouldn't try either. There "used" to be the static opCall that allowed:

Re: Struct constructor, opCall mess.

2014-02-24 Thread monarch_dodra
On Monday, 24 February 2014 at 17:15:10 UTC, Remo wrote: So what is proper/best way to mimic default constructor for struct ? Honestly, you can't, and you shouldn't try either. There "used" to be the static opCall that allowed: auto a = T(); But: a) This is being phased out: If T h

Re: Struct constructor, opCall mess.

2014-02-24 Thread Remo
Also please take a look at those: https://d.puremagic.com/issues/show_bug.cgi?id=7066 There may be some others I've missed; the sheer amount and unresolved state is terrifying. IMHO Issue 7066 is not a bug but a feature. Of course it could be handled i a bit more safe way. This looks like

Re: Struct constructor, opCall mess.

2014-02-24 Thread Remo
Fortunately? Yes I think it is. Of course it could be made a more safe in some way. I think the big advantage of D is that it has 'bridge' to C and C++. This way it appears to be easy to port some C++ code to D. And it appears to be easy to interconnect C++ and D code. (via Dll for example)

Re: Struct constructor, opCall mess.

2014-02-24 Thread Stanislav Blinov
On Monday, 24 February 2014 at 17:15:10 UTC, Remo wrote: Well fortunately it seems to be possible to override init property. Fortunately? I think not. It's an abomination that, IMO, has to be annihilated. Recently Andrei suggested adding more explicit semantics to .init that may give some le

Re: Struct constructor, opCall mess.

2014-02-24 Thread Remo
On Monday, 24 February 2014 at 14:14:43 UTC, Tobias Pankrath wrote: On Monday, 24 February 2014 at 13:56:01 UTC, Remo wrote: Hi, right now I am truing to figure out how the constructors behave in D2. Question 1: why it is not possible to create custom ctor for struct? The design of D reli

Re: Struct constructor, opCall mess.

2014-02-24 Thread Tobias Pankrath
On Monday, 24 February 2014 at 13:56:01 UTC, Remo wrote: Hi, right now I am truing to figure out how the constructors behave in D2. Question 1: why it is not possible to create custom ctor for struct? The design of D relies on the fact that every type has a T.init property that is known t

Struct constructor, opCall mess.

2014-02-24 Thread Remo
Hi, right now I am truing to figure out how the constructors behave in D2. Question 1: why it is not possible to create custom ctor for struct? I know this is not really necessary because you can initialize fields like this. struct S{ int i = 1; } But this is a big problem if one tries to