Re: defining in a module symbols for export

2010-11-23 Thread spir
On Mon, 22 Nov 2010 16:20:07 -0500 Jesse Phillips wrote: > spir Wrote: > > > > === mod.d == > > import std.stdio; > > > > struct S { > > int i; > > void speak() {writeln("i: ",this.i);} > > } > > === __trials__.d === > > import mod; > > > > auto s = S(); > > s.speak(); > > s.i = 1; >

Re: defining in a module symbols for export

2010-11-23 Thread spir
On Mon, 22 Nov 2010 22:17:46 +0100 Pelle Månsson wrote: > On 11/22/2010 08:18 PM, spir wrote: > > Hello, > > > > Let us say I have a parsing library. Now, I want to define parsers in > > stand-alone modules -- for code structuration and reusability. Then, import > > them from apps that need the

Re: defining in a module symbols for export

2010-11-22 Thread Jesse Phillips
spir Wrote: > === mod.d == > import std.stdio; > > struct S { > int i; > void speak() {writeln("i: ",this.i);} > } > === __trials__.d === > import mod; > > auto s = S(); > s.speak(); > s.i = 1; > writeln(s.i); > > void main () { > } Others have answered how to initialize variables, bu

Re: defining in a module symbols for export

2010-11-22 Thread spir
On Mon, 22 Nov 2010 15:11:29 -0500 bearophile wrote: > spir: > > > More generally, I find myself unable to define structured objects at a > > modules's top level. for instancz: > > I suggest to declare global variables and then initialize them in a "static > this() {...}". But generally I sug

Re: defining in a module symbols for export

2010-11-22 Thread Pelle Månsson
On 11/22/2010 08:18 PM, spir wrote: Hello, Let us say I have a parsing library. Now, I want to define parsers in stand-alone modules -- for code structuration and reusability. Then, import them from apps that need them. Is there another way than defining the parser (== list of patterns) at the

Re: defining in a module symbols for export

2010-11-22 Thread bearophile
spir: > More generally, I find myself unable to define structured objects at a > modules's top level. for instancz: I suggest to declare global variables and then initialize them in a "static this() {...}". But generally I suggest you to minimize the number of global variables. Bye, bearophil

defining in a module symbols for export

2010-11-22 Thread spir
Hello, Let us say I have a parsing library. Now, I want to define parsers in stand-alone modules -- for code structuration and reusability. Then, import them from apps that need them. Is there another way than defining the parser (== list of patterns) at the module's top-level. I have nothing a