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;
>
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
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
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
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
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
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