Fixing cyclic import static construction problems

Nick Sabalausky SeeWebsiteToContactMe at semitwist.com
Fri Dec 7 11:28:56 PST 2012


On Thu, 29 Nov 2012 12:39:19 +0100
"Paulo Pinto" <pjmlp at progtools.org> wrote:

> On Thursday, 29 November 2012 at 03:19:55 UTC, Andrei 
> Alexandrescu wrote:
> > On 11/28/12 9:34 PM, Walter Bright wrote:
> >> For discussion:
> > [snip]
> >
> > I'd say we better finish const, immutable, and shared first.
> >
> > Andrei
> 
> +1
> 
> Fully agree.
> 
> Cyclic imports are a minor nuisance that can be easily solvable 
> with better code architecture.
> 

Or just lazy initialization:

    Foo f = blah();

-->

    private Foo _f;
    private bool fInited=false;
    @property Foo f()
    {
        if(!fInited)
        {
            _f = blah();
            fInited = true;
        }

        return _f;
    }

And that boilerplate's trivially wrapped up with a mixin.



More information about the Digitalmars-d mailing list