Fixing cyclic import static construction problems

Paulo Pinto pjmlp at progtools.org
Thu Nov 29 07:23:06 PST 2012


On Thursday, 29 November 2012 at 12:17:49 UTC, Jonathan M Davis 
wrote:
> On Thursday, November 29, 2012 12:39:19 Paulo Pinto 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.
>> 
>> Turbo Pascal/Delphi is the only language that I know fully 
>> allows
>> cyclic dependencies between modules. So this is not that
>> important for most people.
>
> Basic features in the language require static constructors 
> (e.g. static
> variables frequently do), and some things just can't be done 
> without them.
> Andrei's std.benchmark proposal actually doesn't work, because 
> in order to do
> what it does, in needs to mixin in a static constructor and 
> static destructor
> (to set up the benchmarking and record it at the end, I 
> believe). That
> completely falls apart due to cyclical imports. It doesn't 
> actually cause any
> true circular dependencies, but it's treated as such anyway. A 
> _lot_ of us
> have run into this problem and a number of us consider it to be 
> a huge design
> problem in the language. Personally, I'd put it towards the top 
> of design
> mistakes at this point, and I'm very glad to see Walter 
> actually finally being
> willing to do something about this. In the past when I've 
> brought up similar
> solutions, he's been completely opposed to them.
>
> Yes, we have other major issues that need to be resolved, and 
> those may very
> well be of a higher priority, but this is still a very import 
> issue, and it's
> the sort of issue that can probably be implemented with minimal 
> effort. The
> main thing is getting Walter to agree to it and how it will be 
> done. Once a
> decision is made, it wouldn't surprise me if someone like Kenji 
> were able to
> get it done very quickly.
>
> - Jonathan M Davis

Maybe I should keep my mouth shut, because actually I don't 
really use D besides some toy experiments, as there is no place 
for D in the type of work I currently do, either on the job or 
privately.

I like however to point people to D as a possible C++ successor 
as way to do some language publicity, and think that these type 
of discussions might scare D newbies away in what concerns 
language stability, hence my post.

--
Paulo


More information about the Digitalmars-d mailing list