Top 5

Dave Dave_member at pathlink.com
Thu Oct 9 10:41:56 PDT 2008


"Andrei Alexandrescu" <SeeWebsiteForEmail at erdani.org> wrote in message 
news:gcj3u6$1lga$1 at digitalmars.com...
> Ok, per Aarti's suggestion: without speaking officially for Walter, let me 
> ask this - what do you think are the top issues you'd like to see fixed in 
> D?
>
> Andrei

I haven't seen this mentioned yet, so here goes: What to do about reference 
aliasing and its effect on compiler optimizations?

Some background to clarify what I mean by 'reference aliasing':
http://en.wikipedia.org/wiki/Pointer_alias
http://en.wikipedia.org/wiki/Restrict
http://www.cellperformance.com/mike_acton/2006/05/demystifying_the_restrict_keyw.html

I say 'reference' instead of 'pointer' so as to not confuse the issue with 
raw pointers and C's 'restrict'.

I think since D arrays include the length, maybe something could be done 
there because there is enough information at runtime to quickly check for 
memory overlap. Also, a combination of compile time and runtime info. could 
probably do the same for classes, and for struct and primitive value types 
passed by ref.

There doesn't seem to be many of the original scientific computing people 
left posting to this group, nor do I know of any game developers lurking 
about, but it may be important for D's adoption by those groups. I gather it 
certainly used to be an important reason why Fortran developers would not 
switch to C or C++.

I know that invariants and pure functions open the possibility to optimize 
away, but the issues there are:
a) Elements of invariant arrays are not straight-forward to initialize at 
present (requires casting).
b) If used as intended, invariants don't allow re-population of the array 
elements for the same previously allocated array (encourages more memory use 
and pressure on the GC).
c) Pure functions would require new'ing a returned result set, which is 
probably quite a bit slower than a runtime alias check under most 
circumstances.
d) Assuming no aliasing on invariants can still lead to undefined behaviour 
that a runtime check could avoid.

So bottom line is that the issue may need to be solved in a more general way 
than with invariants and pure functions to be really useful.

- Dave




More information about the Digitalmars-d mailing list