digitalmars.D.bugs - link error for 2+ static this()
- BCS (8/8) Jun 01 2006 this gives a link error with somthing about duplicate symbols.
- Thomas Kuehne (11/19) Jun 02 2006 -----BEGIN PGP SIGNED MESSAGE-----
- Walter Bright (2/9) Jun 07 2006 That's because there are two static constructors, which is not legal.
- Carlos Santander (5/15) Jun 07 2006 But it could be caught at compile time, instead, giving an appropriate e...
- Johan Granberg (6/21) Jun 07 2006 quote from the spec
- Derek Parnell (21/41) Jun 07 2006 It doesn't for me. I thought that meant that if one has more than one
- Johan Granberg (20/26) Jun 07 2006 Ok in that case dmd and gdc have implemented this differently
- BCS (21/52) Jun 07 2006 This is the behavior I would expect. If there is some sort of technical
- Carlos Santander (7/67) Jun 07 2006 I would expect that, and I'd prefer for it to be allowed, but if it isn'...
- Derek Parnell (9/30) Jun 07 2006 Me too! I have suggested this to Walter some time back, and there is a
this gives a link error with somthing about duplicate symbols. <code> void main(){} static this(){} static this(){} <\code> DMD 0.158(?) linux not tried on win.
Jun 01 2006
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 BCS schrieb am 2006-06-01:this gives a link error with somthing about duplicate symbols. <code> void main(){} static this(){} static this(){} <\code> DMD 0.158(?) linux not tried on win.Added to DStress as http://dstress.kuehne.cn/nocompile/t/this_12_A.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFEgEz+3w+/yD4P9tIRAs4LAJ9Y0dNAB+IuqXlkKRPzPSWve3we1QCgz9Bb UJfUDGgaFrPBvGgtNtHiXAk= =5Dum -----END PGP SIGNATURE-----
Jun 02 2006
BCS wrote:this gives a link error with somthing about duplicate symbols. <code> void main(){} static this(){} static this(){} <\code>That's because there are two static constructors, which is not legal.
Jun 07 2006
Walter Bright escribió:BCS wrote:But it could be caught at compile time, instead, giving an appropriate error message. -- Carlos Santander Bernalthis gives a link error with somthing about duplicate symbols. <code> void main(){} static this(){} static this(){} <\code>That's because there are two static constructors, which is not legal.
Jun 07 2006
Carlos Santander wrote:Walter Bright escribió:quote from the spec "Order of Static Construction within a Module Within a module, the static construction occurs in the lexical order in which they appear." doesn't this imply that multiple static constructors are legal?BCS wrote:But it could be caught at compile time, instead, giving an appropriate error message.this gives a link error with somthing about duplicate symbols. <code> void main(){} static this(){} static this(){} <\code>That's because there are two static constructors, which is not legal.
Jun 07 2006
On Wed, 07 Jun 2006 22:34:27 +1000, Johan Granberg <lijat.meREM OVEgmail.com> wrote:Carlos Santander wrote:It doesn't for me. I thought that meant that if one has more than one static constructor in a module then they run in lexical order. For example ... module test; class Foo { static this() { ... } } class Bar { static this() { ... } } static this() { . . .} In this case, Foo's ctor runs first, then Bar's and finally the module's. The spec does not mean that one can have multiple class ctors per class or module ctors per module. -- Derek Parnell Melbourne, AustraliaWalter Bright escribió:quote from the spec "Order of Static Construction within a Module Within a module, the static construction occurs in the lexical order in which they appear." doesn't this imply that multiple static constructors are legal?BCS wrote:But it could be caught at compile time, instead, giving an appropriate error message.this gives a link error with somthing about duplicate symbols. <code> void main(){} static this(){} static this(){} <\code>That's because there are two static constructors, which is not legal.
Jun 07 2006
Derek Parnell wrote:It doesn't for me. I thought that meant that if one has more than one static constructor in a module then they run in lexical order. For example .... ... --Derek Parnell Melbourne, AustraliaOk in that case dmd and gdc have implemented this differently this code compiled with gdc-0.18 //begin test.d uint a=0,b=0; static this() { a=1; } static this() { b=2; } void main() { printf("%i, %i\n",a,b); } //end test.d prints this 1, 2
Jun 07 2006
This is the behavior I would expect. If there is some sort of technical problem with multiple constructors than how can you have several static class constructors? I would expect that whatever is done to sequence these would be trivially expendable to module constructors. I would like to see this ability. in some cases it would greatly improve the readability of code. Example: <code> int[] someStaticDataSet; static this(){/* set up someStaticDataSet */ } int useThis(int i){/* function uses someStaticDataSet */ return value;} Object[int] someStaticAA; static this(){/* seeds someStaticAA */ } bool PutThere(Object o, int i) {/* function uses someStaticAA */ return false;} Object GetThat(int i) {/* function uses someStaticDataSet */ return obj;} </code> Lumping the two constructors together serves no purpose from a readability standpoint. Johan Granberg wrote:Derek Parnell wrote:It doesn't for me. I thought that meant that if one has more than one static constructor in a module then they run in lexical order. For example .... ... --Derek Parnell Melbourne, AustraliaOk in that case dmd and gdc have implemented this differently this code compiled with gdc-0.18 //begin test.d uint a=0,b=0; static this() { a=1; } static this() { b=2; } void main() { printf("%i, %i\n",a,b); } //end test.d prints this 1, 2
Jun 07 2006
BCS escribió:This is the behavior I would expect. If there is some sort of technical problem with multiple constructors than how can you have several static class constructors? I would expect that whatever is done to sequence these would be trivially expendable to module constructors. I would like to see this ability. in some cases it would greatly improve the readability of code. Example: <code> int[] someStaticDataSet; static this(){/* set up someStaticDataSet */ } int useThis(int i){/* function uses someStaticDataSet */ return value;} Object[int] someStaticAA; static this(){/* seeds someStaticAA */ } bool PutThere(Object o, int i) {/* function uses someStaticAA */ return false;} Object GetThat(int i) {/* function uses someStaticDataSet */ return obj;} </code> Lumping the two constructors together serves no purpose from a readability standpoint. Johan Granberg wrote:I would expect that, and I'd prefer for it to be allowed, but if it isn't going to work for whatever reason (in this case, linker error), better disallow and report it as an error as soon as possible. I didn't know it worked with gdc. I think that's cool! -- Carlos Santander BernalDerek Parnell wrote:It doesn't for me. I thought that meant that if one has more than one static constructor in a module then they run in lexical order. For example .... ... --Derek Parnell Melbourne, AustraliaOk in that case dmd and gdc have implemented this differently this code compiled with gdc-0.18 //begin test.d uint a=0,b=0; static this() { a=1; } static this() { b=2; } void main() { printf("%i, %i\n",a,b); } //end test.d prints this 1, 2
Jun 07 2006
On Wed, 07 Jun 2006 14:36:40 -0500, Carlos Santander wrote:Me too! I have suggested this to Walter some time back, and there is a syntactical precedence with the way that the 'scope' statements work. -- Derek (skype: derek.j.parnell) Melbourne, Australia "Down with mediocrity!" 8/06/2006 12:08:23 PMI would expect that, and I'd prefer for it to be allowed ... I think that's cool!this code compiled with gdc-0.18 //begin test.d uint a=0,b=0; static this() { a=1; } static this() { b=2; } void main() { printf("%i, %i\n",a,b); } //end test.d prints this 1, 2
Jun 07 2006