digitalmars.D.learn - Initializing global arrays in modules via this()?
- AEon (20/20) Mar 22 2005 Initializing global arrays in modules (i.e. outside functions), someone
- Chris Sauls (8/20) Mar 22 2005 Its a simple mistake: you need to make the module constructor static. I...
- AEon (4/10) Mar 22 2005 Ah thanx... alas since it is not possible to search newsgroups, I was no...
- J C Calvarese (7/8) Mar 22 2005 To a certain extent, you can search the newsgroups:
Initializing global arrays in modules (i.e. outside functions), someone mentioned this() as a solution: <code> module aepar_global; const int MLdataNo = 13; int[] metaData; // Initializing Arrays (before main() is called) this() { metaData.length = MLdataNo; // or metaData.length = metaData.length + MLdataNo; } </code> Alas this yields an error: // aepar_global.d(115): constructor aepar_global.this constructors only are for class definitions And since int[MLdataNo] metaData; does not work either, I am a bit at loss what to do? AEon
Mar 22 2005
Its a simple mistake: you need to make the module constructor static. Ie: The error message could be a little more helpful, I suppose. Maybe by suggesting that what you seem to want is a 'static this()'. -- Chris Sauls AEon wrote:// Initializing Arrays (before main() is called) this() { metaData.length = MLdataNo; // or metaData.length = metaData.length + MLdataNo; } </code> Alas this yields an error: // aepar_global.d(115): constructor aepar_global.this constructors only are for class definitions
Mar 22 2005
Chris Sauls says...Its a simple mistake: you need to make the module constructor static. Ie: The error message could be a little more helpful, I suppose. Maybe by suggesting that what you seem to want is a 'static this()'.Ah thanx... alas since it is not possible to search newsgroups, I was not able to find the initial post, that not doubt was correct. AEon
Mar 22 2005
In article <d1pqbb$aqt$1 digitaldaemon.com>, AEon says.....Ah thanx... alas since it is not possible to search newsgroups, ...To a certain extent, you can search the newsgroups: http://www.digitalmars.com/advancedsearch.html See also: http://www.prowiki.org/wiki4d/wiki.cgi?NewsDmD#NewsreadervsWebInterface jcc7
Mar 22 2005