Thread overview | |||||
---|---|---|---|---|---|
|
January 25, 2006 _arguments in constructor | ||||
---|---|---|---|---|
| ||||
This example should not assert I believe: === module main; class Foo { uint args; this(...) { args = _arguments.length; foreach(TypeInfo typeInfo; _arguments) { typeInfo.print(); } } } int main(char[][] args) { auto foo = new Foo(1, 2, 3); assert(foo.args == 3); return 0; } === I compile with GDC 0.17, om Mac OS X 10.4.4. The output is: TypeInfo[] int int int So it seams that the hidden variable _arguments is included in itself for constructors. // Fredrik Olsson |
January 25, 2006 Re: _arguments in constructor | ||||
---|---|---|---|---|
| ||||
Posted in reply to Fredrik Olsson | Works fine (doesn't assert) w/ dmd v0.144 on either/both WinXP and Linux. In article <dr8js8$2g3j$1@digitaldaemon.com>, Fredrik Olsson says... > >This example should not assert I believe: > >=== >module main; > >class Foo { > uint args; > this(...) { > args = _arguments.length; > foreach(TypeInfo typeInfo; _arguments) { > typeInfo.print(); > } > } >} > >int main(char[][] args) { > auto foo = new Foo(1, 2, 3); > assert(foo.args == 3); > return 0; >} >=== > >I compile with GDC 0.17, om Mac OS X 10.4.4. > >The output is: >TypeInfo[] >int >int >int > >So it seams that the hidden variable _arguments is included in itself for constructors. > >// Fredrik Olsson |
January 26, 2006 Re: _arguments in constructor | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dave | Dave skrev: > Works fine (doesn't assert) w/ dmd v0.144 on either/both WinXP and Linux. > So then it is a GDC specific (or perhaps even OS X specific) bug, I better repost it in D.gnu for safe measure. // Fredrik Olsson > In article <dr8js8$2g3j$1@digitaldaemon.com>, Fredrik Olsson says... >> This example should not assert I believe: >> >> === >> module main; >> >> class Foo { >> uint args; >> this(...) { >> args = _arguments.length; >> foreach(TypeInfo typeInfo; _arguments) { >> typeInfo.print(); >> } >> } >> } >> >> int main(char[][] args) { >> auto foo = new Foo(1, 2, 3); >> assert(foo.args == 3); >> return 0; >> } >> === >> >> I compile with GDC 0.17, om Mac OS X 10.4.4. >> >> The output is: >> TypeInfo[] >> int >> int >> int >> >> So it seams that the hidden variable _arguments is included in itself for constructors. >> >> // Fredrik Olsson > > |
Copyright © 1999-2021 by the D Language Foundation